Submission #306489

#TimeUsernameProblemLanguageResultExecution timeMemory
306489TemmieArt Exhibition (JOI18_art)C++17
100 / 100
207 ms20984 KiB
#include <bits/stdc++.h> typedef long long ll; int main() { std::ios::sync_with_stdio(0); std::cin.tie(0); int n; std::cin >> n; std::vector <std::pair <ll, ll>> a(n); for (auto& p : a) std::cin >> p.first >> p.second; std::sort(a.begin(), a.end()); ll ans = a[0].second; for (ll i = 0, sum = 0, max = a[0].first; (int)i < n; i++) { sum += a[i].second; max = std::max(max, a[i].first - sum + a[i].second); ans = std::max(ans, sum + max - a[i].first); } std::cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...