| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 195661 | T0p_ | Art Exhibition (JOI18_art) | C++14 | 2 ms | 256 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;
#define pb push_back
struct data{
long long sz, vl;
bool operator < (const data & o) const{
return sz < o.sz;
}
};
long long a[500500], b[500500];
vector<data> v;
int main(){
int n;
long long ans = 0;
scanf(" %d",&n);
for(int i=0 ; i<n ; i++){
long long sz, vl;
scanf(" %lld %lld",&sz,&vl);
ans = max(ans, vl);
v.pb({sz, vl});
}
v.pb({0, 0});
sort(v.begin(), v.end());
for(int i=1 ; i<=n ; i++) v[i].vl += v[i-1].vl;
b[0] = 1e18;
for(int i=1 ; i<=n ; i++){
a[i] = v[i].vl - v[i].sz;
a[i] = max(a[i], a[i-1]);
b[i] = v[i-1].vl - v[i].sz;
b[i] = min(b[i], b[i-1]);
ans = max(ans, a[i] - b[i-1]);
}
printf("%lld\n",ans);
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... | ||||
