# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1222479 | Bui_Quoc_Cuong | Art Exhibition (JOI18_art) | C++20 | 40 ms | 5188 KiB |
#include<bits/stdc++.h>
using namespace std;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (int)(a.size())
const int N = 3e5 + 5;
const int oo = 2e9;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
int n;
array <ll, 2> artwork[N];
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define taskname "kieuoanh"
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
cin >> n;
FOR(i, 1, n) cin >> artwork[i][0] >> artwork[i][1];
sort(artwork + 1, artwork + 1 + n);
ll ans = - 1e18;
FOR(i, 1, n){
ll S = 0;
ll mn = 1e18, mx = 0;
FOR(j, i, n){
S+= artwork[j][1];
mn = min(mn, artwork[j][0]);
mx = max(mx, artwork[j][0]);
ans = max(ans, S - (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... |