# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100549 | 2019-03-12T07:48:41 Z | Pro_ktmr | Sushi (JOI16_sushi) | C++14 | 12000 ms | 14272 KB |
#include<bits/stdc++.h> using namespace std; int N,Q; int S[400000]; int A[25000],B[25000],P[25000]; set<int> z2; vector<int> z; priority_queue<int> s[50002]; int main(){ scanf("%d%d", &N, &Q); for(int i=0; i<N; i++) scanf("%d", S+i); for(int i=0; i<Q; i++){ scanf("%d%d%d", A+i, B+i, P+i); A[i]--; z2.insert(A[i]); z2.insert(B[i]); } z2.insert(0); z2.insert(N); for(auto itr=z2.begin(); itr!=z2.end(); itr++) z.push_back(*itr); for(int i=0; i<N; i++){ int idx = upper_bound(z.begin(), z.end(), i) - z.begin() - 1; s[idx].push(S[i]); } // for(int q=0; q<Q; q++){ int start = lower_bound(z.begin(), z.end(), A[q]) - z.begin(); int fin = lower_bound(z.begin(), z.end(), B[q]) - z.begin(); int p = P[q]; if(start < fin){ for(int i=start; i<fin; i++){ int tmp = s[i].top(); if(tmp > p){ s[i].pop(); s[i].push(p); p = tmp; } } } else{ for(int i=start; i<z.size()-1; i++){ int tmp = s[i].top(); if(tmp > p){ s[i].pop(); s[i].push(p); p = tmp; } } for(int i=0; i<fin; i++){ int tmp = s[i].top(); if(tmp > p){ s[i].pop(); s[i].push(p); p = tmp; } } } P[q] = p; printf("%d\n", P[q]); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 2304 KB | Output is correct |
2 | Correct | 9 ms | 2176 KB | Output is correct |
3 | Correct | 9 ms | 2176 KB | Output is correct |
4 | Correct | 8 ms | 2176 KB | Output is correct |
5 | Correct | 8 ms | 2176 KB | Output is correct |
6 | Correct | 8 ms | 2176 KB | Output is correct |
7 | Correct | 8 ms | 2176 KB | Output is correct |
8 | Correct | 8 ms | 2176 KB | Output is correct |
9 | Correct | 9 ms | 2148 KB | Output is correct |
10 | Correct | 8 ms | 2176 KB | Output is correct |
11 | Correct | 13 ms | 2176 KB | Output is correct |
12 | Correct | 13 ms | 2176 KB | Output is correct |
13 | Correct | 20 ms | 2176 KB | Output is correct |
14 | Correct | 10 ms | 2176 KB | Output is correct |
15 | Correct | 12 ms | 2176 KB | Output is correct |
16 | Correct | 6 ms | 2176 KB | Output is correct |
17 | Correct | 4 ms | 1920 KB | Output is correct |
18 | Correct | 3 ms | 1920 KB | Output is correct |
19 | Correct | 3 ms | 1920 KB | Output is correct |
20 | Correct | 3 ms | 1920 KB | Output is correct |
21 | Correct | 4 ms | 1920 KB | Output is correct |
22 | Correct | 4 ms | 1920 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 99 ms | 10212 KB | Output is correct |
2 | Correct | 137 ms | 9052 KB | Output is correct |
3 | Correct | 55 ms | 7020 KB | Output is correct |
4 | Correct | 99 ms | 10420 KB | Output is correct |
5 | Correct | 108 ms | 10348 KB | Output is correct |
6 | Correct | 83 ms | 10348 KB | Output is correct |
7 | Correct | 104 ms | 10348 KB | Output is correct |
8 | Correct | 118 ms | 10320 KB | Output is correct |
9 | Correct | 62 ms | 7044 KB | Output is correct |
10 | Correct | 84 ms | 8876 KB | Output is correct |
11 | Correct | 100 ms | 7020 KB | Output is correct |
12 | Correct | 83 ms | 9068 KB | Output is correct |
13 | Correct | 115 ms | 10220 KB | Output is correct |
14 | Correct | 91 ms | 8940 KB | Output is correct |
15 | Correct | 60 ms | 6968 KB | Output is correct |
16 | Correct | 105 ms | 10356 KB | Output is correct |
17 | Correct | 97 ms | 10300 KB | Output is correct |
18 | Correct | 103 ms | 10416 KB | Output is correct |
19 | Correct | 85 ms | 10448 KB | Output is correct |
20 | Correct | 81 ms | 10348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 2304 KB | Output is correct |
2 | Correct | 9 ms | 2176 KB | Output is correct |
3 | Correct | 9 ms | 2176 KB | Output is correct |
4 | Correct | 8 ms | 2176 KB | Output is correct |
5 | Correct | 8 ms | 2176 KB | Output is correct |
6 | Correct | 8 ms | 2176 KB | Output is correct |
7 | Correct | 8 ms | 2176 KB | Output is correct |
8 | Correct | 8 ms | 2176 KB | Output is correct |
9 | Correct | 9 ms | 2148 KB | Output is correct |
10 | Correct | 8 ms | 2176 KB | Output is correct |
11 | Correct | 13 ms | 2176 KB | Output is correct |
12 | Correct | 13 ms | 2176 KB | Output is correct |
13 | Correct | 20 ms | 2176 KB | Output is correct |
14 | Correct | 10 ms | 2176 KB | Output is correct |
15 | Correct | 12 ms | 2176 KB | Output is correct |
16 | Correct | 6 ms | 2176 KB | Output is correct |
17 | Correct | 4 ms | 1920 KB | Output is correct |
18 | Correct | 3 ms | 1920 KB | Output is correct |
19 | Correct | 3 ms | 1920 KB | Output is correct |
20 | Correct | 3 ms | 1920 KB | Output is correct |
21 | Correct | 4 ms | 1920 KB | Output is correct |
22 | Correct | 4 ms | 1920 KB | Output is correct |
23 | Correct | 99 ms | 10212 KB | Output is correct |
24 | Correct | 137 ms | 9052 KB | Output is correct |
25 | Correct | 55 ms | 7020 KB | Output is correct |
26 | Correct | 99 ms | 10420 KB | Output is correct |
27 | Correct | 108 ms | 10348 KB | Output is correct |
28 | Correct | 83 ms | 10348 KB | Output is correct |
29 | Correct | 104 ms | 10348 KB | Output is correct |
30 | Correct | 118 ms | 10320 KB | Output is correct |
31 | Correct | 62 ms | 7044 KB | Output is correct |
32 | Correct | 84 ms | 8876 KB | Output is correct |
33 | Correct | 100 ms | 7020 KB | Output is correct |
34 | Correct | 83 ms | 9068 KB | Output is correct |
35 | Correct | 115 ms | 10220 KB | Output is correct |
36 | Correct | 91 ms | 8940 KB | Output is correct |
37 | Correct | 60 ms | 6968 KB | Output is correct |
38 | Correct | 105 ms | 10356 KB | Output is correct |
39 | Correct | 97 ms | 10300 KB | Output is correct |
40 | Correct | 103 ms | 10416 KB | Output is correct |
41 | Correct | 85 ms | 10448 KB | Output is correct |
42 | Correct | 81 ms | 10348 KB | Output is correct |
43 | Correct | 1925 ms | 14144 KB | Output is correct |
44 | Correct | 2005 ms | 13972 KB | Output is correct |
45 | Correct | 1802 ms | 10644 KB | Output is correct |
46 | Correct | 2095 ms | 14060 KB | Output is correct |
47 | Correct | 2031 ms | 14272 KB | Output is correct |
48 | Execution timed out | 12081 ms | 14208 KB | Time limit exceeded |
49 | Halted | 0 ms | 0 KB | - |