| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 123161 | Hideo | Art Exhibition (JOI18_art) | C++14 | 603 ms | 150136 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define vl vector < ll >
#define pi pair < int, int >
#define pl pair < ll, ll >
#define pii pair < int, pi >
#define vii vector < pi >
const int N = 5e5 + 7;
const int INF = 1e9 + 7;
pl a[N];
ll st[N][32], pr[N];
ll ans;
int n;
void build (){
for (int i = 1; i <= 30; i++){
for (int j = 1; j + (1 << i) - 1 <= n; j++){
st[j][i] = max(st[j][i - 1], st[j + (1 << (i - 1))][i - 1]);
}
}
}
ll get (int l, int r){
int pw = log2(r - l + 1);
return max(st[l][pw], st[r - (1 << pw) + 1][pw]);
}
main(){
cin >> n;
for (int i = 1; i <= n; i++)
scanf("%lld%lld", &a[i].fr, &a[i].sc);
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; i++)
pr[i] = pr[i - 1] + a[i].sc;
for (int i = 1; i <= n; i++)
st[i][0] = pr[i] - a[i].fr;
build();
for (int i = 1; i <= n; i++){
ans = max(ans, a[i].fr - pr[i - 1] + get(i, n));
}
cout << ans;
}
컴파일 시 표준 에러 (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... | ||||
