Submission #1088545

# Submission time Handle Problem Language Result Execution time Memory
1088545 2024-09-14T15:14:38 Z Staheos Art Exhibition (JOI18_art) C++14
0 / 100
0 ms 348 KB
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	long long n;
	cin >> n;
	auto ab = new pair<long long, long long>[n];

	for (long long i = 0; i < n; i++)
	{
		cin >> ab[i].first >> ab[i].second;
	}
	std::sort(ab, ab + n);

	long long amin = 0;
	long long s = 0;
	long long m = 0;
	for (long long i = 0; i < n; i++)
	{
		s += ab[i].second;
		while (amin < i && (s - (ab[i].first - ab[amin].first) < s - ab[amin].second - (ab[i].first - ab[amin + 1].first)))
		{
			s -= ab[amin].second;
			amin++;
		}
		if (s - (ab[i].first - ab[amin].first) > m)
		{
			m = s - (ab[i].first - ab[amin].first);
		}
	}

	cout << m << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -