Submission #1093117

#TimeUsernameProblemLanguageResultExecution timeMemory
1093117thumbsupArt Exhibition (JOI18_art)C++17
50 / 100
1056 ms20820 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define se second #define pb push_back #define ep emplace_back #define lwb lower_bound #define upb upper_bound #define gcd(x, y) __gcd(x, y) #define lcm(x, y) x * y / __gcd(x, y) const int mod = 1e9 + 7; const int inf = 1e9 + 7; const int mxN = 5e5 + 5; const int block = 450; const int base = 311; const int LOG = 19; int n; pair<ll, ll> a[mxN]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i].fi >> a[i].se; } sort(a + 1, a + n + 1); ll ans = 0; for (int i = 1; i <= n; i++) { ll s = 0; for (int j = i; j <= n; j++) { s += a[j].se; ans = max(ans, s - a[j].fi + a[i].fi); } } cout << ans; } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...