제출 #717756

#제출 시각아이디문제언어결과실행 시간메모리
717756ToxtaqArt Exhibition (JOI18_art)C++17
50 / 100
1074 ms11988 KiB
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<pair<long long, long long>>arts(n + 1); for(int i = 1;i <= n;++i){ cin >> arts[i].first >> arts[i].second; } sort(arts.begin(), arts.end()); vector<long long>pref(n + 1); for(int i = 1;i <= n;++i){ pref[i] = pref[i - 1] + arts[i].second; } long long mx = 0; for(int i = 1;i <= n;++i){ for(int j = i;j <= n;++j){ long long a_max = arts[j].first, a_min = arts[i].first; long long S = pref[j] - pref[i - 1]; mx = max(mx, (S - (a_max - a_min))); } } cout << mx; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...