# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
134793 | onjo0127 | Sushi (JOI16_sushi) | C++11 | 4545 ms | 82348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int sn = 632;
int N, X[400009];
priority_queue<int> pq[700], L[700];
inline int geti(int i) { return (i-1) / sn; }
void go(int s, int e, int &x) {
if(s > e) return;
int id = geti(s), bs = id*sn+1, be = min(bs + sn - 1, N);
if(s != bs || e < be) {
for(int i=bs; i<=be; i++) {
L[id].push(-X[i]);
X[i] = -L[id].top();
L[id].pop();
}
L[id] = pq[id] = priority_queue<int>();
for(int i=s; i<=min(be, e); i++) if(X[i] > x) swap(x, X[i]);
for(int i=bs; i<=be; i++) pq[id].push(X[i]);
go(be + 1, e, x);
}
else {
L[id].push(-x);
pq[id].push(x);
x = pq[id].top(); pq[id].pop();
go(be + 1, e, x);
}
}
int main() {
int Q; scanf("%d%d",&N,&Q);
for(int i=1; i<=N; i++) {
scanf("%d",&X[i]);
pq[geti(i)].push(X[i]);
}
while(Q--) {
int S, T, P; scanf("%d%d%d",&S,&T,&P);
int x = P;
if(S <= T) go(S, T, x);
else {
go(S, N, x);
go(1, T, x);
}
printf("%d\n", x);
}
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... |