# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1069246 | raduv | Fountain (eJOI20_fountain) | C++14 | 127 ms | 17212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <utility>
#pragma GCC optimize("O3", "Ofast", "unroll-loops")
#pragma GCC target ("avx2")
const int MAXN = 100'000;
const int LOG = 18;
using namespace std;
int rmq[LOG + 1][MAXN + 1], cap[LOG + 1][MAXN + 1];
pair<int, int> stiva[MAXN + 1];
int ns;
int main()
{
int n, q, i, diam, p, a, b;
scanf("%d%d", &n, &q);
for( i = 1; i <= n; i++ ){
scanf("%d%d", &diam, &cap[0][i]);
while(ns > 0 && diam > stiva[ns].first)
rmq[0][stiva[ns--].second] = i;
stiva[++ns] = {diam, i};
}
while(ns > 0)
rmq[0][stiva[ns--].second] = i;
for ( p = 1; p <= LOG; p++ ){
for( i = 1; i <= n; i++ ){
rmq[p][i] = rmq[p - 1][rmq[p - 1][i]];
cap[p][i] = cap[p - 1][i] + cap[p - 1][rmq[p - 1][i]];
}
}
while(q--){
scanf("%d%d", &a, &b);
for( i = LOG; i >= 0; i-- ){
if(cap[i][a] < b){
b -= cap[i][a];
a = rmq[i][a];
}
}
printf("%d\n", a);
}
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... |