# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
273323 | lookcook | Divide and conquer (IZhO14_divide) | C++17 | 3 ms | 2688 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 100005;
int psa[3][maxn]; // 0 = x, 1 = gold, 2 = energy
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
for (int i = 0; i < 3; i++) for (int j = 0; j < maxn; j++) psa[i][j] = 0;
int n;
cin >> n;
int last = 0;
int xs[n+1], gs[n+1], ds[n+1];
for (int i = 1; i <= n; i++) {
int x, g, d;
cin >> x >> g >> d;
xs[i] = x;
gs[i] = g;
ds[i] = d;
int tmp = x;
x -= last;
last = tmp;
psa[0][i] += x;
psa[1][i] += g;
psa[2][i] += d;
}
for (int i = 0; i < 3; i++) for (int j = 1; j < maxn; j++) psa[i][j] += psa[i][j-1];
int best = 0;
for (int l = 1; l <= n; l++) {
int pos = l;
for (int i = 17; i >= 0; i--) {
if (pos+(1<<i) < maxn && psa[0][pos+(1<<i)]-psa[0][l] <= psa[2][pos+(1<<i)]-psa[2][l-1]) {
pos += (1<<i);
}
}
int gold = psa[1][pos]-psa[1][l-1];
best = max(best, gold);
}
cout << best << '\n';
}
컴파일 시 표준 에러 (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... |