Submission #666846

#TimeUsernameProblemLanguageResultExecution timeMemory
666846Koful123Art Exhibition (JOI18_art)C++17
100 / 100
188 ms20688 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl "\n" #define pb push_back #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() void solve(){ int n; cin >> n; vector<pair<int,int>> v(n); for(auto &[x,y] : v){ cin >> x >> y; } int maxi = 0,sum = 0,ans = 0; sort(all(v)); for(int i = 0; i < n; i++){ maxi = max(maxi,v[i].ff - sum); sum = sum + v[i].ss; ans = max(ans,maxi + sum - v[i].ff); } cout << ans << endl; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); 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...