# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
972957 | oyber | Art Exhibition (JOI18_art) | C++14 | 1 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
vector<pair<int, int>> v;
for (int i = 0; i < n; i++) {
int a, b;
scanf("%d %d", &a, &b);
v.push_back(make_pair(a, b));
}
sort(v.begin(), v.end());
int score = v[0].second;
int best_score = score;
for (int i = 1; i < n; i++) {
int dist = v[i].first - v[i-1].first;
int diff = v[i].second - dist;
if (score+diff > v[i].second) {
score += diff;
} else {
score = v[i].second;
}
if (score > best_score) {
best_score = score;
}
//printf("%d\n", score);
}
printf("%d\n", best_score);
}
Compilation message (stderr)
# | 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... |