# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1034006 | cowwycow | Art Exhibition (JOI18_art) | C++14 | 149 ms | 20564 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.
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define name "aaaaaa"
using ll = long long;
using pll = pair<ll, ll>;
using ld = long double;
void file(){
ios_base::sync_with_stdio(0); cin.tie(0);
if(fopen(name".inp", "r")) {
freopen(name".inp", "r", stdin);
freopen(name".out", "w", stdout);
}
}
const int maxn = 5e5 + 5;
pll a[maxn];
ll pre[maxn];
void solve (){
int n; cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i].first >> a[i].second;
}
sort(a + 1, a + n + 1);
for(int i = 1; i <= n; i++){
a[i].second = a[i - 1].second + a[i].second;
}
ll dis = 1e18, res = 0;
for(int i = 1; i <= n; i++){
dis = min(dis, a[i - 1].second - a[i].first);
res = max(res, a[i].second - a[i].first - dis);
}
cout << res;
}
int main(){
file();
int t = 1;
//cin >> t;
while(t--){
solve();
}
}
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... |