This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
using namespace std;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
typedef long long ll;
typedef long double ld;
const ll SZ = 2e5 + 100, INF = 1e9 + 10, MX = 4e5 + 210;
vector<pair<ll, ll>> vec;
ll n;
int main() {
fastInp;
cin >> n;
vec.resize(n);
for (auto& c : vec) cin >> c.first >> c.second;
sort(vec.begin(), vec.end());
ll mxsum = vec[0].second, cur = vec[0].second;
for (int i = 1; i < n; i++) {
cur += vec[i].second;
cur -= (vec[i].first - vec[i - 1].first);
mxsum = max(mxsum, cur);
if (cur < 0) cur = vec[i].second;
}
cout << mxsum;
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... |