Submission #129133

# Submission time Handle Problem Language Result Execution time Memory
129133 2019-07-11T17:52:06 Z miguel Art Exhibition (JOI18_art) C++14
0 / 100
2 ms 376 KB
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
const ll mod = 1e9 + 7;
int n, net[500004];
vector <pi> art;
int mn[500004];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n;
    art.resize(n+1);
    for(int i=1; i<=n; i++) cin>>art[i].x>>art[i].y;
    art[0]={0, 0};
    sort(art.begin(), art.end());
    for(int i=1; i<=n; i++) art[i].x-=art[1].x;

    net[1]=art[1].y;
    for(int i=2; i<=n; i++) net[i]=art[i].y-(art[i].x-art[i-1].x);
    for(int i=1; i<=n; i++) net[i]+=net[i-1];

    mn[n]=net[n];
    for(int i=n-1; i>=1; i--) mn[i]=max(mn[i+1], net[i]);
    int ans=0;
    for(int i=1; i<=n; i++){
        ans=max(ans, mn[i]-net[i-1]+art[i].x);
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -