Submission #254642

#TimeUsernameProblemLanguageResultExecution timeMemory
254642alradArt Exhibition (JOI18_art)C++17
50 / 100
1097 ms20820 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() int main() { ios_base :: sync_with_stdio(0); cin.tie(0) , cout.tie(0); int n; cin >> n; vector<pair<long long , int> > a; for (int i = 0; i < n; i++) { long long u; int v; cin >> u >> v; a.push_back({u , v}); } sort(all(a)); long long ans = 0LL; for (int i = 0; i < n; i++) { long long sum = 0 , mx = 0 , mn = 5e18; for (int j = i; j < n; j++) { sum += a[j].second; mx = max(mx , a[j].first); mn = min(mn , a[j].first); //cout << "cur ans " << sum - (mx - mn) << '\n'; //cout << "Mx " << mx << " " << mn << " " << sum << '\n'; //cout << "seg " << i + 1 << " " << j + 1 << '\n' << '\n'; ans = max(ans , sum - (mx - mn)); } } 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...