# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1108390 | vjudge1 | Art Exhibition (JOI18_art) | C++17 | 129 ms | 12116 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.
/*
This solution was made by hihihah (Handle codeforces : hihihah)
The local date and time is: Mon Nov 4 10:42:59 2024
The UTC date and time is: Mon Nov 4 03:42:59 2024
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
const int N = 1e9 + 7;
int n;
pii a[500009];
ll f[500009];
void hihihah(){
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 ++)
f[i] = f[i - 1] + a[i].second;
ll mn = -a[1].first;
ll res = 0;
for (int i = 1; i <= n; i ++) {
mn = min (mn, f[i - 1] - a[i].first);
res = max (res, f[i] - a[i].first - mn);
}
cout << res;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
#define orz "mo"
if(fopen(orz".inp", "r")){
freopen(orz".inp", "r", stdin);
freopen(orz".out", "w", stdout);
}
int t = 1;
// cin >> t;
while(t --){
hihihah();
}
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s";
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... |