| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 21835 | ulna | 금 캐기 (IZhO14_divide) | C++11 | 96 ms | 10572 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
// why am I so weak
int n;
long long x[100055], g[100055], d[100055];
typedef pair<long long, int> P;
#define ft first
#define sd second
int main() {
// sigma(ei ... ej) >= x[j] - x[i]
// e[j] - e[i - 1] >= x[j] - x[i]
// x[i] - e[i - 1] >= x[j] - e[j]
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%lld %lld %lld", &x[i], &g[i], &d[i]);
if (i) {
g[i] += g[i - 1];
d[i] += d[i - 1];
}
}
set<P> s;
long long res = g[0];
s.insert(P(x[0], 0));
for (int i = 0; i < n; i++) {
res = max(res, g[i] - g[i - 1]);
{
auto ite = s.lower_bound(P(x[i] - d[i], -1));
if (ite != s.end()) {
res = max(res, g[i] - (ite->sd == 0 ? 0ll : g[ite->sd - 1]));
}
}
if (x[i] - d[i - 1] > s.rbegin()->ft) {
s.insert(P(x[i] - d[i - 1], i));
}
}
printf("%lld\n", res);
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... | ||||
