# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
60391 | gusfring | Art Exhibition (JOI18_art) | C++14 | 39 ms | 4656 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;
const int MAXN = 5e3 + 5;
typedef long long ll;
#define sz first
#define val second
pair<ll, ll> C[MAXN];
int N;
int main(){
scanf("%d", &N);
for(int i=1; i<=N; ++i) scanf("%lld %lld", &C[i].sz, &C[i].val);
sort(C + 1, C + N + 1);
ll res = 0;
for(int i=1; i<=N; ++i){
ll sum = 0;
for(int j=i; j<=N; ++j){
sum += C[j].val;
res = max(res, sum - (C[j].sz - C[i].sz));
}
}
printf("%lld\n", res);
return 0;
}
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... |