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 all(v) v.begin(), v.end()
typedef long long ll;
ll n, a, b, mn, ans, sum;
vector<pair<ll, ll>> v;
int main(void){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 0; i < n; i++){
cin >> a >> b;
v.emplace_back(a, b);
}
sort(all(v));
mn = 1e18;
for(int i = 0; i < n; i++){
auto&[a, b] = v[i];
mn = min(mn, sum - a);
sum += b;
ans = max(ans, sum - a - mn);
}
cout << ans;
return 0;
}
Compilation message (stderr)
art.cpp: In function 'int main()':
art.cpp:21:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
21 | auto&[a, b] = v[i];
| ^
# | 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... |