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 <iomanip>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <limits>
#define endl '\n'
typedef unsigned long long int u64;
typedef long long int i64;
typedef unsigned int u32;
typedef int i32;
typedef unsigned short u16;
typedef short i16;
using namespace std;
int main() {
i32 n;
cin>> n;
vector<pair<long long, int>> arr(n);
for (auto& i: arr) {
cin>>i.first>>i.second;
}
sort(arr.begin(), arr.end());
i64 ans = 0, accumulate = 0, low = 0;
for (int i = 0; i < n; ++i) {
low = min(low, accumulate - arr[i].first);
accumulate += arr[i].second;
ans = max(ans, accumulate - arr[i].first - low);
}
cout << ans << endl;
return 0;
}
# | 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... |