Submission #1093123

#TimeUsernameProblemLanguageResultExecution timeMemory
1093123ch0c0p13Art Exhibition (JOI18_art)C++14
100 / 100
156 ms28756 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define ull unsigned long long #define pii pair<int,int> #define pll pair<long long, long long> #define fi first #define se second #define all(a) (a).begin(), (a).end() #define pb push_back #define lwb lower_bound #define upb upper_bound #define TASKNAME "NAME" void init() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ///freopen(TASKNAME".INP","r",stdin); freopen(TASKNAME".OUT","w",stdout); } const int maxN = 1e6+5; const ll INF = 2e9, MOD = 1e9+7, INFLL = 2e18; const double epsilon = 1e-3; int n; pll a[maxN]; ll sum[maxN], mx[maxN]; int main() { init(); cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i].fi >> a[i].se; } sort(a + 1, a + n + 1); ll res = 0; for(int i = 1; i <= n; i++) { sum[i] = sum[i-1] + a[i].se; mx[i] = max(mx[i-1], a[i].fi - sum[i-1]); res = max(res, sum[i] - a[i].fi + mx[i]); } cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...