답안 #1072051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1072051 2024-08-23T13:42:58 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 2396 KB
#include <iostream>
#include <algorithm>
#include <vector>

#define fs first
#define sc second
using namespace std;
using ll = long long int;

const int N = 5e5 + 5;
pair<ll, ll> a[N];
ll ans = 0, mx = 0, pref[N];

bool cmp(pair<ll, ll> a, pair<ll, ll> b) {
	return a.fs < b.fs;
}

int main() {
	int n; cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i].fs >> a[i].sc;

	sort(a+1, a+n+1, cmp);
	for (int i = 1; i <= n; ++i)
		pref[i] = pref[i - 1] + a[i].sc;

	for (int i = 1; i < n; ++i) {
		mx = max(mx, a[i].fs - pref[i-1]);
		ans = max(ans, pref[i] - a[i].fs + mx);
	}

	cout << ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Incorrect 1 ms 2396 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Incorrect 1 ms 2396 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Incorrect 1 ms 2396 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Incorrect 1 ms 2396 KB Output isn't correct
6 Halted 0 ms 0 KB -