# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
38481 | 14kg | 금 캐기 (IZhO14_divide) | C++11 | 66 ms | 5408 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <algorithm>
#define N 100001
#define INF 999999999999999999
#define LL long long
#define max2(x,y) (x>y?x:y)
using namespace std;
struct DNC {
int w, g, e;
} in[N];
int n, list_len;
LL out;
pair<LL, LL> d[N];
pair<LL, int> list[N];
int search(long long num) {
pair<LL, int> temp = { num,0 };
pair<LL, int> *w = upper_bound(list + 1, list + list_len + 1, temp);
return w->second;
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d %d %d", &in[i].w, &in[i].g, &in[i].e);
for (int i = 1; i <= n; i++)
d[i] = { d[i - 1].first - (LL)(in[i].w - in[i - 1].w) + (LL)in[i].e,
d[i - 1].second + (LL)in[i].g };
list[0] = { -INF,0 };
for (int i = n; i >= 1; i--)
if (d[i].first > list[list_len].first)
list[++list_len] = { d[i].first,i };
for (int i = 1; i <= n; i++) {
int w = search(d[i].first - (LL)in[i].e);
out = max2(out, d[w].second - d[i - 1].second);
}
printf("%lld", out);
}
컴파일 시 표준 에러 (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... |