Submission #55986

# Submission time Handle Problem Language Result Execution time Memory
55986 2018-07-09T09:15:14 Z 노영훈(#1562) Sushi (JOI16_sushi) C++11
5 / 100
414 ms 21280 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(){
    multiset<int> S;
    for(int i=1; i<=n; i++) cin>>A[i], S.insert(A[i]);
    for(int i=1; i<=q; i++){
        int s,t,x; cin>>s>>t>>x;
        cout<<*S.rbegin()<<'\n';
        S.erase(*S.rbegin());
        S.insert(x);
    }
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>q;
    if(n*q<=1e8) solve1();
    else solve2();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 18 ms 376 KB Output is correct
2 Correct 15 ms 488 KB Output is correct
3 Correct 15 ms 580 KB Output is correct
4 Correct 14 ms 580 KB Output is correct
5 Correct 15 ms 580 KB Output is correct
6 Correct 15 ms 580 KB Output is correct
7 Correct 13 ms 664 KB Output is correct
8 Correct 17 ms 684 KB Output is correct
9 Correct 15 ms 684 KB Output is correct
10 Correct 15 ms 684 KB Output is correct
11 Correct 14 ms 688 KB Output is correct
12 Correct 19 ms 688 KB Output is correct
13 Correct 23 ms 688 KB Output is correct
14 Correct 23 ms 688 KB Output is correct
15 Correct 23 ms 688 KB Output is correct
16 Correct 3 ms 688 KB Output is correct
17 Correct 2 ms 688 KB Output is correct
18 Correct 2 ms 688 KB Output is correct
19 Correct 2 ms 688 KB Output is correct
20 Correct 2 ms 688 KB Output is correct
21 Correct 2 ms 688 KB Output is correct
22 Correct 2 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 414 ms 21280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 376 KB Output is correct
2 Correct 15 ms 488 KB Output is correct
3 Correct 15 ms 580 KB Output is correct
4 Correct 14 ms 580 KB Output is correct
5 Correct 15 ms 580 KB Output is correct
6 Correct 15 ms 580 KB Output is correct
7 Correct 13 ms 664 KB Output is correct
8 Correct 17 ms 684 KB Output is correct
9 Correct 15 ms 684 KB Output is correct
10 Correct 15 ms 684 KB Output is correct
11 Correct 14 ms 688 KB Output is correct
12 Correct 19 ms 688 KB Output is correct
13 Correct 23 ms 688 KB Output is correct
14 Correct 23 ms 688 KB Output is correct
15 Correct 23 ms 688 KB Output is correct
16 Correct 3 ms 688 KB Output is correct
17 Correct 2 ms 688 KB Output is correct
18 Correct 2 ms 688 KB Output is correct
19 Correct 2 ms 688 KB Output is correct
20 Correct 2 ms 688 KB Output is correct
21 Correct 2 ms 688 KB Output is correct
22 Correct 2 ms 688 KB Output is correct
23 Incorrect 414 ms 21280 KB Output isn't correct
24 Halted 0 ms 0 KB -