Submission #680984

#TimeUsernameProblemLanguageResultExecution timeMemory
680984AlexandruabcdeArt Exhibition (JOI18_art)C++14
100 / 100
317 ms48264 KiB
#include <bits/stdc++.h> using namespace std; typedef pair <long long, int> PLLI; typedef long long LL; constexpr int NMAX = 5e5 + 5; constexpr LL INF = 1LL * 1e18; int N; PLLI A[NMAX]; LL sp[NMAX]; void Read () { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> N; for (int i = 1; i <= N; ++ i ) cin >> A[i].first >> A[i].second; sort(A+1, A+N+1); } void Solve () { for (int i = 1; i <= N; ++ i ) sp[i] = sp[i-1] + 1LL * A[i].second; set <LL> S; LL ans = -INF; for (int i = 1; i <= N; ++ i ) { S.insert(sp[i-1] - A[i].first); LL value = *(S.begin()); ans = max(ans, sp[i] - A[i].first - value); } cout << ans << '\n'; } int main () { Read(); Solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...