# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1158627 | blick | Art Exhibition (JOI18_art) | C++20 | 0 ms | 320 KiB |
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
using namespace std;
bool cmp(pair<ll, ll> a, pair<ll, ll> b) {
if(abs(a.F-a.S)==abs(b.F-b.S)) {
if(a.F==b.F) {
return a.S>b.S;
}
return a.F<b.F;
}
return abs(a.F-a.S)<abs(b.F-b.S);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
vector<pair<ll, ll>> a(n);
for(int i = 0; i < n; i++) {
cin>>a[i].S>>a[i].F;
}
sort(a.begin(), a.end(), cmp);
ll S=0, mn=LLONG_MAX, mx=LLONG_MIN, ans = 0;
for(int i = 0; i < n; i++) {
S+=a[i].F;
mn=min(mn, a[i].S);
mx=max(mx, a[i].S);
ans = max(ans, S-(mx-mn));
# | 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... |