Submission #715750

#TimeUsernameProblemLanguageResultExecution timeMemory
715750aykhnArt Exhibition (JOI18_art)C++14
100 / 100
571 ms24732 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define OPT ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define pii pair<int,int> #define pll pair<ll,ll> #define pull pair<ull,ull> #define endl "\n" #define all(v) v.begin(), v.end() #define mpr make_pair #define pb push_back #define ts to_string #define fi first #define se second #define inf 0x3F3F3F3F #define bpc __builtin_popcount #define print(v) for(int i = 0; i < v.size(); i++) \ cout << v[i] << " "; \ cout<<endl; int main() { int n; cin >> n; vector<pll> v(n); ll res = 0; for (int i = 0; i < n; i++) { cin >> v[i].fi >> v[i].se; res = max(res, v[i].se); } sort(all(v)); ll sum = 0; vector<ll> rest(n); for (int i = 0; i < n; i++) { if (v[i].fi >= sum) sum = v[i].fi; sum += v[i].se; rest[i] = sum; } for (int i = 0; i < n; i++) { res = max(res, rest[i] - v[i].fi); } cout << res << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...