# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
867884 | iskhakkutbilim | Art Exhibition (JOI18_art) | C++17 | 1093 ms | 20820 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n; cin >> n;
int ans = LLONG_MIN;
vector< pair<int, int> > a(n);
for(auto &x : a) cin >> x.ff >> x.ss;
sort(all(a));
for(int i = 0;i < n; i++){
int mx = a[i].ff, mn = a[i].ff;
ans = max(ans, a[i].ss);
int sum = a[i].ss;
for(int j = i+1;j < n; j++){
mx = max(mx, a[j].ff);
mn = min(mn, a[j].ff);
sum+= a[j].ss;
ans = max(ans, sum - (mx - mn));
}
}
cout << ans;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |