# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47024 | leejseo | Art Exhibition (JOI18_art) | C++17 | 293 ms | 12540 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 <stdio.h>
#include <utility>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long lld;
typedef pair<lld, lld> pll;
lld ans;
int N;
int main(void){
scanf("%d", &N);
lld X, Y, S[N+1];
pll U[N];
S[0] = 0;
for (int i=0; i<N; i++){
scanf("%lld%lld", &X, &Y);
U[i] = make_pair(X, Y);
}
sort(U, U+N);
for (int i=0; i<N; i++){
S[i+1] = S[i] + U[i].second;
}
Y = -(U[0].first);
for (int i=1; i<=N; i++){
X = S[i] - U[i-1].first;
ans = max(ans, X - Y);
if (i == N) break;
Y = min(Y, S[i]-U[i].first);
}
printf("%lld", ans);
}
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... |