| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 24910 | kdh9949 | 코알라 (JOI13_koala) | C++14 | 103 ms | 7584 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, t[100010];
ll en, d, a, x[100010], b[100010], xx[100010], dp[100010];
const ll inf = 3e18;
const int sz = (1 << 17);
struct Seg{
ll dat[2 * sz];
void ini(){ fill(dat + 1, dat + 2 * sz, -inf); }
void upd(int x, ll v){
x += sz - 1; dat[x] = v;
for(x /= 2; x; x /= 2) dat[x] = max(dat[2 * x], dat[2 * x + 1]);
}
ll get(int s, int e){
ll ret = -inf;
for(s += sz - 1, e += sz - 1; s <= e; s /= 2, e /= 2){
if(s % 2 == 1) ret = max(ret, dat[s++]);
if(e % 2 == 0) ret = max(ret, dat[e--]);
}
return ret;
}
} S;
int main(){
scanf("%lld%lld%lld%lld%d", x, &en, &d, &a, &n);
for(int i = 0; i <= n; i++){
if(i) scanf("%lld%lld", x + i, b + i);
x[i] = en - x[i];
xx[i] = x[i] % d;
}
sort(xx, xx + n + 2);
for(int i = 1; i <= n; i++){
t[i] = (int)(lower_bound(xx, xx + n + 2, x[i] % d) - xx + 1);
}
S.ini();
S.upd(1, 0);
for(int i = n; i >= 0; i--){
dp[i] = max(S.get(t[i], n + 2) - (x[i] / d * a), S.get(1, t[i] - 1) - (x[i] / d * a + a)) + b[i];
S.upd(t[i], dp[i] + (x[i] / d * a));
}
printf("%lld\n", dp[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... | ||||
