답안 #1088545

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
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';
}
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -