Submission #503496

# Submission time Handle Problem Language Result Execution time Memory
503496 2022-01-08T08:04:21 Z OrazB Art Exhibition (JOI18_art) C++14
0 / 100
0 ms 328 KB
#include <bits/stdc++.h>
#define N 500005
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second
using namespace std;

ll n, sm, ans = -1e18, mx;
pii a[N];

int main ()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i].ff >> a[i].ss;
	sort(a + 1, a + n + 1);
	mx = -a[1].ff;
	for (int i = 1; i <= n; i++){
		sm += a[i].ss;
		ans = max(ans, (sm - a[i].ff) - mx);
		mx = min(mx, sm - a[i + 1].ff);
	}	
	cout << ans;
}	
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -