제출 #771018

#제출 시각아이디문제언어결과실행 시간메모리
771018kirakaminski968Art Exhibition (JOI18_art)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N; cin >> N; vector<pair<long long,long long>> vec(N+1); for(int i = 1;i<=N;++i) cin >> vec[i].first >> vec[i].second; //first is size, second is value sort(vec.begin(),vec.end()); //sorted by size vector<long long> pref(N+1); pref[0] = 0; for(int i = 1;i<=N;++i) pref[i] = pref[i-1]+vec[i].second; //prefix sums on value long long cur = vec[1].first, ans = 0; for(int i = 1;i<=N;++i){ cur = max(cur,vec[i].first-pref[i-1]); ans = max(ans,pref[i]-vec[i].first+cur); cout << cur << " " << ans << "\n"; } cout << ans << "\n"; 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...