Submission #1107780

# Submission time Handle Problem Language Result Execution time Memory
1107780 2024-11-02T05:35:52 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
using namespace std;
const int N=5e5+5;
const int inf=1e9;
const int mod=1e9+7;
const int N1=1e5+25;
vector<pair<int,int> >v;
vector<int>v1;
int dp[N];
struct edge{
    int v,time;
};
signed main(){
//   freopen("input.txt", "r", stdin);
 //  freopen("output.txt", "w", stdout);
    boost;
    int n;
    cin>>n;
    v.push_back({0,0});
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        v.push_back({x,y});
    }
    sort(v.begin(),v.end());
    int cnt=0;
    for(int i=1;i<=n;i++){
        cnt+=v[i].second;
        dp[i]=cnt-v[i].first;
    }
    cnt=v[1].first;
    int ans=0;
    for(int i=2;i<=n;i++){
        ans=max(ans,dp[i]+cnt);
        cnt=min(cnt,cnt+v[i-1].second-v[i-1].first+v[i].first);
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -