# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1109194 | kh0i | Art Exhibition (JOI18_art) | C++17 | 171 ms | 8324 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
const int N = 5e5 + 3;
int n;
pair<ll, ll> x[N];
void solve(){
cin >> n;
for(int i = 1; i <= n; ++i)
cin >> x[i].F >> x[i].S;
sort(x + 1, x + n + 1);
ll res = 0, mx = 0, sum = 0;
for(int i = 1; i <= n; ++i){
mx = max(mx, x[i].F - sum);
sum += x[i].S;
res = max(res, sum - x[i].F + mx);
}
cout << res;
}
signed main(){
cin.tie(nullptr)->sync_with_stdio(false);
#define task "troll"
if(fopen(task".inp", "r")){
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int test = 1;
// cin >> test;
while(test--)
solve();
return 0;
}
컴파일 시 표준 에러 (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... |