답안 #55990

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
55990 2018-07-09T09:23:02 Z 노영훈(#1562) Sushi (JOI16_sushi) C++11
20 / 100
721 ms 21452 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=400010, inf=2e9;

int n, q;
int A[MX];

void solve1(){
    for(int i=1; i<=n; i++) cin>>A[i];
        for(int i=1; i<=q; i++){
            int s, t, x; cin>>s>>t>>x;
            for(int jj=s; jj<=t+n; jj++){
                int j=(jj-1)%n+1;
                if(x<A[j]) swap(x,A[j]);
                if(j==t) break;
            }
            cout<<x<<'\n';
        }
}

void solve2(){
    map<int, int> cnt;
    for(int i=1; i<=n; i++) cin>>A[i], cnt[A[i]]++;
    for(int i=1; i<=q; i++){
        int s,t,x; cin>>s>>t>>x;
        int y=cnt.rbegin()->first;
        if(x<y){
            cout<<y<<'\n';
            cnt[y]--;
            if(cnt[y]==0) cnt.erase(y);
            cnt[x]++;
        }
        else{
            cout<<x<<'\n';
        }
    }
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>q;
    if(n*q<=1e8) solve1();
    else solve2();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 376 KB Output is correct
2 Correct 12 ms 552 KB Output is correct
3 Correct 12 ms 552 KB Output is correct
4 Correct 12 ms 552 KB Output is correct
5 Correct 12 ms 552 KB Output is correct
6 Correct 12 ms 556 KB Output is correct
7 Correct 11 ms 596 KB Output is correct
8 Correct 11 ms 772 KB Output is correct
9 Correct 14 ms 772 KB Output is correct
10 Correct 14 ms 772 KB Output is correct
11 Correct 15 ms 812 KB Output is correct
12 Correct 14 ms 852 KB Output is correct
13 Correct 19 ms 852 KB Output is correct
14 Correct 22 ms 852 KB Output is correct
15 Correct 23 ms 852 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 3 ms 852 KB Output is correct
18 Correct 2 ms 852 KB Output is correct
19 Correct 3 ms 852 KB Output is correct
20 Correct 3 ms 852 KB Output is correct
21 Correct 2 ms 852 KB Output is correct
22 Correct 2 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 706 ms 21376 KB Output is correct
2 Correct 550 ms 21376 KB Output is correct
3 Correct 45 ms 21376 KB Output is correct
4 Correct 721 ms 21436 KB Output is correct
5 Correct 263 ms 21436 KB Output is correct
6 Correct 177 ms 21436 KB Output is correct
7 Correct 160 ms 21436 KB Output is correct
8 Correct 279 ms 21436 KB Output is correct
9 Correct 43 ms 21436 KB Output is correct
10 Correct 230 ms 21436 KB Output is correct
11 Correct 58 ms 21436 KB Output is correct
12 Correct 244 ms 21436 KB Output is correct
13 Correct 618 ms 21452 KB Output is correct
14 Correct 536 ms 21452 KB Output is correct
15 Correct 55 ms 21452 KB Output is correct
16 Correct 678 ms 21452 KB Output is correct
17 Correct 242 ms 21452 KB Output is correct
18 Correct 172 ms 21452 KB Output is correct
19 Correct 157 ms 21452 KB Output is correct
20 Correct 218 ms 21452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 376 KB Output is correct
2 Correct 12 ms 552 KB Output is correct
3 Correct 12 ms 552 KB Output is correct
4 Correct 12 ms 552 KB Output is correct
5 Correct 12 ms 552 KB Output is correct
6 Correct 12 ms 556 KB Output is correct
7 Correct 11 ms 596 KB Output is correct
8 Correct 11 ms 772 KB Output is correct
9 Correct 14 ms 772 KB Output is correct
10 Correct 14 ms 772 KB Output is correct
11 Correct 15 ms 812 KB Output is correct
12 Correct 14 ms 852 KB Output is correct
13 Correct 19 ms 852 KB Output is correct
14 Correct 22 ms 852 KB Output is correct
15 Correct 23 ms 852 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 3 ms 852 KB Output is correct
18 Correct 2 ms 852 KB Output is correct
19 Correct 3 ms 852 KB Output is correct
20 Correct 3 ms 852 KB Output is correct
21 Correct 2 ms 852 KB Output is correct
22 Correct 2 ms 852 KB Output is correct
23 Correct 706 ms 21376 KB Output is correct
24 Correct 550 ms 21376 KB Output is correct
25 Correct 45 ms 21376 KB Output is correct
26 Correct 721 ms 21436 KB Output is correct
27 Correct 263 ms 21436 KB Output is correct
28 Correct 177 ms 21436 KB Output is correct
29 Correct 160 ms 21436 KB Output is correct
30 Correct 279 ms 21436 KB Output is correct
31 Correct 43 ms 21436 KB Output is correct
32 Correct 230 ms 21436 KB Output is correct
33 Correct 58 ms 21436 KB Output is correct
34 Correct 244 ms 21436 KB Output is correct
35 Correct 618 ms 21452 KB Output is correct
36 Correct 536 ms 21452 KB Output is correct
37 Correct 55 ms 21452 KB Output is correct
38 Correct 678 ms 21452 KB Output is correct
39 Correct 242 ms 21452 KB Output is correct
40 Correct 172 ms 21452 KB Output is correct
41 Correct 157 ms 21452 KB Output is correct
42 Correct 218 ms 21452 KB Output is correct
43 Incorrect 669 ms 21452 KB Output isn't correct
44 Halted 0 ms 0 KB -