Submission #1128341

#TimeUsernameProblemLanguageResultExecution timeMemory
1128341mnbvcxz123Art Exhibition (JOI18_art)C++20
100 / 100
173 ms8624 KiB
#include "bits/stdc++.h" #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; using ll=long long; constexpr ll INF = 1e18, mod = 1e9 + 7, N = 2e5 + 5; void solve(){ ll n,m; cin >> n; vector<pair<ll,ll>>v; v.push_back({0ll, 0ll}); ll a,b; for(int i = 0; i < n; i++){ cin >> a >> b; v.push_back({a,b}); } sort(v.begin(),v.end()); ll maxi = 0; ll cur = 0; for(int i = 1; i <= n; i++){ cur += v[i].second; cur = max(cur, v[i].first + v[i].second); maxi = max(maxi, cur - v[i].first); } cout << maxi << endl; } int main() { fast; ll 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...