#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PUB push_back
struct art{
ll sz, val;
};
int N;
ll ans = 0, cnt = 0;
vector<art> data;
bool comp(art a, art b){
if(a.sz == b.sz) return a.val < b.val;
return a.sz < b.sz;
}
int main(){
cin >> N;
data.PUB({0,0});
for(int i=1;i<=N;i++){
ll a, b;
cin >> a >> b;
data.PUB({a, b});
}
sort(data.begin(), data.end(), comp);
cnt += data[1].val;
ans = cnt;
for(int i=2;i<=N;i++){
cnt += data[i].val-(data[i].sz-data[i-1].sz);
if(cnt <= 0){
cnt = data[i].val;
}
ans = max(ans, cnt);
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |