Submission #502442

#TimeUsernameProblemLanguageResultExecution timeMemory
502442zoriankaArt Exhibition (JOI18_art)C++17
100 / 100
502 ms20764 KiB
//#pragma GCC optimize("O3,unroll-loops") //#pragma GCC optimize("fast-math") //#pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> using namespace std; using ll = long long; #define int ll void solve() { int n; cin >> n; vector<pair<ll, ll>> a(n); for (int i = 0; i < n; i++) { cin >> a[i].first >> a[i].second; } sort(a.begin(), a.end()); // vector<pair<ll, ll>> b; // for (auto p : a) { // if (b.empty()) // b.push_back(p); // else if (b.back().first == p.first) { // b.back().second += p.second; // } else // b.push_back(p); // } ll ans = a[0].second; ll sum = a[0].second; for (int i = 1; i < n; i++) { sum += a[i].second - (a[i].first - a[i - 1].first); if(sum < a[i].second) sum = a[i].second; ans = max(ans,sum); } cout << ans; } signed main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif int t = 1; // cin >> t; while (t--) 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...