# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1159718 | eldorbek_008 | Art Exhibition (JOI18_art) | C++17 | 0 ms | 328 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
int32_t main() {
ios :: sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<array<int, 2>> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1];
}
sort(a.begin(), a.end());
vector<int> p(n);
for (int i = 0; i < n; i++) {
p[i] = (i == 0 ? 0 : p[i - 1]) + a[i][1];
}
int j = 0, ans = 0;
for (int i = 0; i < n; i++) {
int d = a[i][0] - a[j][0];
int s = p[i] - (j == 0 ? 0 : p[j - 1]);
if (s <= d) {
j = i;
}
d = a[i][0] - a[j][0];
s = p[i] - (j == 0 ? 0 : p[j - 1]);
ans = max(ans, s - d);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |