Submission #1018084

# Submission time Handle Problem Language Result Execution time Memory
1018084 2024-07-09T14:01:45 Z ag_1204 Art Exhibition (JOI18_art) C++14
0 / 100
0 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pii pair<int,int>
#define vi vector<int>
#define si set<int>
#define pb push_back
 
void solve() {
    int n; cin>>n;
    vector<pii> v(n);
    for (int i=0;i<n;i++) {
        cin>>v[i].first>>v[i].second;
    }
    sort(v.begin(),v.end());
    int ans=v[0].second;
    int curr=ans;
    for (int i=1;i<n;i++) {
        curr+=v[i-1].first;
        curr+=v[i].second;
        curr-=v[i].first;
        ans=max(ans,curr);
    }
    cout<<ans<<endl;
    return;
}
 
int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int tt=1; //cin>>tt;
	while(tt--) {
	    solve();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -