Submission #913883

# Submission time Handle Problem Language Result Execution time Memory
913883 2024-01-20T11:34:52 Z nika7878 Art Exhibition (JOI18_art) C++14
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
#define int long long
signed main() {
	int n;
	cin >> n;
	vector<pair<int, int>> a(n+1);
	for(int i=0; i<n; i++)
	{
		cin >> a[i].f >> a[i].s;
	}
	sort(a.begin(), a.end());
	for(int i=1; i<n; i++)
	{
		a[i].s=a[i-1].s+a[i].s;
	}
	int ans=0, x=0;
	for(int i=0; i<n; i++)
	{
		if (i == 0) x = max(x, a[i].f);
		else x=max(x, a[i].f-a[i-1].s);
		ans=max(ans, a[i].s-a[i].f+x);
	}
	cout << ans << endl;
 
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -