제출 #493930

#제출 시각아이디문제언어결과실행 시간메모리
493930ahmeterenArt Exhibition (JOI18_art)C++17
50 / 100
1085 ms20664 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long const int N = 1e5 + 5; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // #ifndef ONLINE_JUDGE // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); // #endif ll n, cevap = 0; cin >> n; vector<pair<ll, ll>> vec(n); for(int i = 0; i < n; i++) cin >> vec[i].first >> vec[i].second; sort(vec.begin(), vec.end()); for(int l = 0; l < n; l++) { ll sum = 0, mx = 0, mn = 1e16; for(int r = l; r < n; r++) { sum += vec[r].second; mn = min(mn, vec[r].first); mx = max(mx, vec[r].first); cevap = max(cevap, sum - (mx - mn)); } } cout << cevap << '\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...