Submission #202336

# Submission time Handle Problem Language Result Execution time Memory
202336 2020-02-15T13:47:40 Z someone_aa Art Exhibition (JOI18_art) C++17
0 / 100
5 ms 248 KB
#include <bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 500100;
vector<pair<ll,ll> > v;
ll pref[maxn], n;

int main() {
	cin>>n;
	ll a, b;
	for(int i=1;i<=n;i++) {
		cin>>a>>b;
		v.pb({a, b});
	} sort(v.begin(), v.end());

	ll maxv = v[0].first;
	ll result = 0LL;
	for(int i=1;i<=n;i++) {
		pref[i] = pref[i-1] + v[i-1].second;
		result = max(result, pref[i] - v[i-1].first + maxv);
		maxv = max(maxv, v[i-1].first + pref[i-1]);
	}
	cout<<result<<"\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -