답안 #55989

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
55989 2018-07-09T09:17:24 Z 노영훈(#1562) Sushi (JOI16_sushi) C++11
5 / 100
718 ms 21308 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;
        cout<<y<<'\n';
        cnt[y]--;
        if(cnt[y]==0) cnt.erase(y);
        cnt[x]++;
    }
}

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 11 ms 376 KB Output is correct
3 Correct 12 ms 536 KB Output is correct
4 Correct 12 ms 628 KB Output is correct
5 Correct 11 ms 708 KB Output is correct
6 Correct 12 ms 708 KB Output is correct
7 Correct 11 ms 708 KB Output is correct
8 Correct 11 ms 812 KB Output is correct
9 Correct 12 ms 828 KB Output is correct
10 Correct 13 ms 828 KB Output is correct
11 Correct 13 ms 828 KB Output is correct
12 Correct 16 ms 828 KB Output is correct
13 Correct 20 ms 828 KB Output is correct
14 Correct 21 ms 828 KB Output is correct
15 Correct 23 ms 828 KB Output is correct
16 Correct 6 ms 828 KB Output is correct
17 Correct 2 ms 828 KB Output is correct
18 Correct 2 ms 828 KB Output is correct
19 Correct 3 ms 828 KB Output is correct
20 Correct 3 ms 828 KB Output is correct
21 Correct 2 ms 828 KB Output is correct
22 Correct 2 ms 828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 718 ms 21308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 376 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 12 ms 536 KB Output is correct
4 Correct 12 ms 628 KB Output is correct
5 Correct 11 ms 708 KB Output is correct
6 Correct 12 ms 708 KB Output is correct
7 Correct 11 ms 708 KB Output is correct
8 Correct 11 ms 812 KB Output is correct
9 Correct 12 ms 828 KB Output is correct
10 Correct 13 ms 828 KB Output is correct
11 Correct 13 ms 828 KB Output is correct
12 Correct 16 ms 828 KB Output is correct
13 Correct 20 ms 828 KB Output is correct
14 Correct 21 ms 828 KB Output is correct
15 Correct 23 ms 828 KB Output is correct
16 Correct 6 ms 828 KB Output is correct
17 Correct 2 ms 828 KB Output is correct
18 Correct 2 ms 828 KB Output is correct
19 Correct 3 ms 828 KB Output is correct
20 Correct 3 ms 828 KB Output is correct
21 Correct 2 ms 828 KB Output is correct
22 Correct 2 ms 828 KB Output is correct
23 Incorrect 718 ms 21308 KB Output isn't correct
24 Halted 0 ms 0 KB -