Submission #1111953

# Submission time Handle Problem Language Result Execution time Memory
1111953 2024-11-13T12:43:45 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair <int,int>
#define f first 
#define s second 
const int N=5e5+5;
const int INF=1e16;

int n,ans=0,mx=0,mn=INF,sum=0,pos,tmp;
pii p[N]; // size , value

bool cmp(pii x,pii y){
    if(abs(pos-x.f)!=abs(pos-y.f)) return abs(pos-x.f)<abs(pos-y.f);
    else return x.s>y.s;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> p[i].f >> p[i].s;
        if(p[i].s>tmp) tmp=p[i].s,pos=p[i].f;
    }
    sort(p+1,p+1+n,cmp);
    for(int i=1;i<=n;i++){
        auto [a,b]=p[i];
        mx=max(mx,a);
        mn=min(mn,a);
        sum+=b;
        ans=max(ans,sum-(mx-mn));
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -