# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1085961 | kiethm07 | Art Exhibition (JOI18_art) | C++11 | 1 ms | 508 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>
#define pii pair<int,int>
#define iii pair<int,pii>
#define fi first
#define se second
#define vi vector<int>
#define all(x) x.begin(),x.end()
#define TEXT "a"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int inf = 1e9 + 7;
const ld eps = 1e-8;
const double pi = acos(-1);
const int N = 5e5 + 5;
struct node{
ll a, b;
bool operator < (const node& N) const{
if (a != N.a) return a < N.a;
return b < N.b;
}
node(){}
};
int n;
node v[N];
int main(){
cin.tie(0) -> sync_with_stdio(0);
if (fopen(TEXT".inp","r")){
freopen(TEXT".inp","r",stdin);
freopen(TEXT".out","w",stdout);
}
ll res = LLONG_MIN;
cin >> n;
for (int i = 1; i <= n; i++){
cin >> v[i].a >> v[i].b;
}
sort(v + 1,v + 1 + n);
v[0].a = v[1].a;
v[0].b = 0;
ll p = 0;
ll cur = v[0].a;
for (int i = 1; i <= n; i++){
p += v[i].b;
res = max(res,p - v[i].a + cur);
cur = max(cur,v[i].a - p);
}
cout << res << "\n";
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... |