제출 #717761

#제출 시각아이디문제언어결과실행 시간메모리
717761ToxtaqArt Exhibition (JOI18_art)C++17
50 / 100
1078 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>P(n + 1); for(int i = 1;i <= n;++i){ P[i] = P[i - 1] + arts[i].second + arts[i - 1].first - arts[i].first; // cout << "P[" << i << "]=" << P[i] << '\n'; } long long mx = 0; for(int i = 1;i <= n;++i){ for(int j = i;j <= n;++j){ long long num = (P[j] - P[i - 1]) - arts[i - 1].first + arts[i].first; mx = max(mx, num); } } 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...