#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#define int long long
int32_t main(){
int n = 0;
cin >> n;
map <int, int> mp;
for(int i = 0; i < n; i++){
int a = 0, b = 0;
cin >> a >> b;
mp[a] += b;
}
vector <pair<int, int>> eserler;
for(auto tmp : mp){
eserler.push_back(tmp);
}
int pref[(int)(eserler.size() + 1)];
pref[0] = 0;
for(int i = 0; i < eserler.size(); i++){
pref[i + 1] = pref[i] + eserler[i].second;
}
int cevap = 0, onceki = LLONG_MAX;
for(int i = 0; i < eserler.size(); i++){
onceki = min(onceki, pref[i] - eserler[i].first);
cevap = max(cevap, pref[i + 1] - eserler[i].first - onceki);
}
cout << cevap << endl;
}
| # | 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... |