# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
767265 | rainboy | 금 캐기 (IZhO14_divide) | C11 | 33 ms | 5824 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#define N 100000
long long max(long long a, long long b) { return a > b ? a : b; }
int main() {
static int xx[N], ii[N];
static long long yy[N], zz[N], uu[N];
int n, cnt, i, j;
long long v, ans;
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d%lld%lld", &xx[i], &yy[i], &zz[i]);
for (i = 1; i < n; i++)
yy[i] += yy[i - 1], zz[i] += zz[i - 1];
cnt = 0;
for (i = 0; i < n; i++) {
uu[i] = (long long) xx[i] - (i == 0 ? 0 : zz[i - 1]);
if (cnt == 0 || uu[ii[cnt - 1]] < uu[i])
ii[cnt++] = i;
}
ans = 0;
for (j = n - 1; j >= 0; j--) {
v = xx[j] - zz[j];
while (cnt && uu[i = ii[cnt - 1]] >= v) {
ans = max(ans, yy[j] - (i == 0 ? 0 : yy[i - 1]));
cnt--;
}
}
printf("%lld\n", ans);
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... |