제출 #717755

#제출 시각아이디문제언어결과실행 시간메모리
717755ToxtaqArt Exhibition (JOI18_art)C++17
50 / 100
1093 ms19380 KiB
#include<bits/stdc++.h> using namespace std; int main() { 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...