#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
class Solve {
public:
void solve() {
int tuxn;
cin >> tuxn;
vector<pair<int,int>> tuxv(tuxn);
for (int tuxi = 0; tuxi < tuxn; tuxi++) {
cin >> tuxv[tuxi].first >> tuxv[tuxi].second;
}
sort(tuxv.begin(), tuxv.end());
int tuxans = 0;
for (int tuxl = 0; tuxl < tuxn; tuxl++) {
int tuxsum = 0;
for (int tuxr = tuxl; tuxr < tuxn; tuxr++) {
tuxsum += tuxv[tuxr].second;
tuxans = max(
tuxans,
tuxsum - (tuxv[tuxr].first - tuxv[tuxl].first)
);
}
}
cout << tuxans << endl;
}
};
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
Solve tuxz;
tuxz.solve();
}
| # | 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... |