Submission #1115661

#TimeUsernameProblemLanguageResultExecution timeMemory
1115661staszic_ojuzArt Exhibition (JOI18_art)C++17
0 / 100
1 ms336 KiB
#include <iostream> #include <algorithm> #include <cmath> #include <queue> #include <vector> #include <stack> #include <unordered_map> using namespace std; typedef long long ll; struct dzielo { ll s; ll v; }; struct triple { ll a; ll b; ll c; }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; vector<dzielo> arts(n); for(ll i = 0; i < n; i++) { ll s, v; cin >> s >> v; arts[i].s = s; arts[i].v = v; } sort(arts.begin(), arts.end(), [](dzielo a, dzielo b) {return a.s < b.s;}); ll l = arts[0].s, p = arts[0].s; ll s = arts[0].v; ll mx = s - p + l; for(ll i = 1; i < n; i++) { l = min(l, arts[i].s); p = max(p, arts[i].s); s+=arts[i].v; mx = max(mx, s - p + l); //cout << l << " " << p << " " << s << endl; } cout << mx; 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...