#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#include <cmath>
#include <map>
#include <random>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <queue>
#include <limits.h>
using namespace std;
int main () {
int N;
cin >> N;
vector<pair<int64_t,int64_t>> vec(N);
for (int i = 0; i < N; i++) {
cin >> vec[i].first >> vec[i].second;
}
sort(vec.begin(), vec.end());
vector<int64_t> pref(N + 1); pref[0] = 0; for (int i = 1; i <= N; i++) pref[i] = pref[i - 1] + vec[i - 1].second;
int64_t myMax = 0;
for (int i = 0; i < N; i++) {
for (int j = i; j < N; j++) {
//cout << i << " " << j << " " << pref[j + 1] - pref[i] + vec[i].first - vec[j].first << '\n';
myMax = max(myMax, pref[j + 1] - pref[i] + vec[i].first - vec[j].first);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |