# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
55970 | 2018-07-09T08:41:28 Z | 강태규(#1561) | Sushi (JOI16_sushi) | C++11 | 8528 ms | 70812 KB |
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <unordered_map> #include <functional> #include <cstring> #include <cmath> #include <ctime> #include <cstdlib> using namespace std; typedef long long llong; typedef long double ld; typedef pair<int, int> pii; typedef pair<llong, llong> pll; const int t = 700; int n, q, g; int v[400000]; priority_queue<int> mx[t]; priority_queue<int, vector<int>, greater<int>> pass[t]; void reconstruct(int x) { for (int i = x * t; i < (x + 1) * t && i < n; ++i) { pass[x].push(v[i]); v[i] = pass[x].top(); pass[x].pop(); } while (!pass[x].empty()) pass[x].pop(); } void construct(int x) { while (!mx[x].empty()) mx[x].pop(); for (int i = x * t; i < (x + 1) * t && i < n; ++i) { mx[x].push(v[i]); } } int main() { scanf("%d%d", &n, &q); for (int i = 0; i < n; ++i) { scanf("%d", v + i); } g = (n - 1) / t + 1; for (int i = 0; i < t; ++i) { for (int j = i * t; j < (i + 1) * t && j < n; ++j) { mx[i].push(v[j]); } } while (q--) { int s, e, p; scanf("%d%d%d", &s, &e, &p); --s; --e; int sg = s / t; int eg = e / t; reconstruct(sg); reconstruct(eg); if (sg == eg && s <= e) { for (int i = s; i <= e; ++i) { if (p < v[i]) swap(p, v[i]); } } else { for (int i = s; i < (sg + 1) * t && i < n; ++i) { if (p < v[i]) swap(p, v[i]); } for (int i = (sg + 1) % g; i != eg; i = (i + 1) % g) { pass[i].push(p); mx[i].push(p); p = mx[i].top(); mx[i].pop(); } for (int i = eg * t; i <= e; ++i) { if (p < v[i]) swap(p, v[i]); } } construct(sg); construct(eg); printf("%d\n", p); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 299 ms | 504 KB | Output is correct |
2 | Correct | 259 ms | 648 KB | Output is correct |
3 | Correct | 272 ms | 720 KB | Output is correct |
4 | Correct | 321 ms | 720 KB | Output is correct |
5 | Correct | 251 ms | 728 KB | Output is correct |
6 | Correct | 265 ms | 880 KB | Output is correct |
7 | Correct | 111 ms | 880 KB | Output is correct |
8 | Correct | 116 ms | 880 KB | Output is correct |
9 | Correct | 255 ms | 880 KB | Output is correct |
10 | Correct | 289 ms | 880 KB | Output is correct |
11 | Correct | 273 ms | 880 KB | Output is correct |
12 | Correct | 265 ms | 880 KB | Output is correct |
13 | Correct | 299 ms | 880 KB | Output is correct |
14 | Correct | 301 ms | 880 KB | Output is correct |
15 | Correct | 273 ms | 884 KB | Output is correct |
16 | Correct | 252 ms | 884 KB | Output is correct |
17 | Correct | 3 ms | 884 KB | Output is correct |
18 | Correct | 2 ms | 884 KB | Output is correct |
19 | Correct | 2 ms | 884 KB | Output is correct |
20 | Correct | 3 ms | 884 KB | Output is correct |
21 | Correct | 3 ms | 884 KB | Output is correct |
22 | Correct | 3 ms | 884 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5797 ms | 70620 KB | Output is correct |
2 | Correct | 5627 ms | 70620 KB | Output is correct |
3 | Correct | 2191 ms | 70620 KB | Output is correct |
4 | Correct | 5414 ms | 70620 KB | Output is correct |
5 | Correct | 5041 ms | 70620 KB | Output is correct |
6 | Correct | 5730 ms | 70620 KB | Output is correct |
7 | Correct | 5828 ms | 70660 KB | Output is correct |
8 | Correct | 5232 ms | 70660 KB | Output is correct |
9 | Correct | 1943 ms | 70660 KB | Output is correct |
10 | Correct | 4464 ms | 70660 KB | Output is correct |
11 | Correct | 2162 ms | 70660 KB | Output is correct |
12 | Correct | 4854 ms | 70660 KB | Output is correct |
13 | Correct | 5591 ms | 70660 KB | Output is correct |
14 | Correct | 5405 ms | 70716 KB | Output is correct |
15 | Correct | 2194 ms | 70716 KB | Output is correct |
16 | Correct | 5328 ms | 70812 KB | Output is correct |
17 | Correct | 4530 ms | 70812 KB | Output is correct |
18 | Correct | 5573 ms | 70812 KB | Output is correct |
19 | Correct | 5635 ms | 70812 KB | Output is correct |
20 | Correct | 6077 ms | 70812 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 299 ms | 504 KB | Output is correct |
2 | Correct | 259 ms | 648 KB | Output is correct |
3 | Correct | 272 ms | 720 KB | Output is correct |
4 | Correct | 321 ms | 720 KB | Output is correct |
5 | Correct | 251 ms | 728 KB | Output is correct |
6 | Correct | 265 ms | 880 KB | Output is correct |
7 | Correct | 111 ms | 880 KB | Output is correct |
8 | Correct | 116 ms | 880 KB | Output is correct |
9 | Correct | 255 ms | 880 KB | Output is correct |
10 | Correct | 289 ms | 880 KB | Output is correct |
11 | Correct | 273 ms | 880 KB | Output is correct |
12 | Correct | 265 ms | 880 KB | Output is correct |
13 | Correct | 299 ms | 880 KB | Output is correct |
14 | Correct | 301 ms | 880 KB | Output is correct |
15 | Correct | 273 ms | 884 KB | Output is correct |
16 | Correct | 252 ms | 884 KB | Output is correct |
17 | Correct | 3 ms | 884 KB | Output is correct |
18 | Correct | 2 ms | 884 KB | Output is correct |
19 | Correct | 2 ms | 884 KB | Output is correct |
20 | Correct | 3 ms | 884 KB | Output is correct |
21 | Correct | 3 ms | 884 KB | Output is correct |
22 | Correct | 3 ms | 884 KB | Output is correct |
23 | Correct | 5797 ms | 70620 KB | Output is correct |
24 | Correct | 5627 ms | 70620 KB | Output is correct |
25 | Correct | 2191 ms | 70620 KB | Output is correct |
26 | Correct | 5414 ms | 70620 KB | Output is correct |
27 | Correct | 5041 ms | 70620 KB | Output is correct |
28 | Correct | 5730 ms | 70620 KB | Output is correct |
29 | Correct | 5828 ms | 70660 KB | Output is correct |
30 | Correct | 5232 ms | 70660 KB | Output is correct |
31 | Correct | 1943 ms | 70660 KB | Output is correct |
32 | Correct | 4464 ms | 70660 KB | Output is correct |
33 | Correct | 2162 ms | 70660 KB | Output is correct |
34 | Correct | 4854 ms | 70660 KB | Output is correct |
35 | Correct | 5591 ms | 70660 KB | Output is correct |
36 | Correct | 5405 ms | 70716 KB | Output is correct |
37 | Correct | 2194 ms | 70716 KB | Output is correct |
38 | Correct | 5328 ms | 70812 KB | Output is correct |
39 | Correct | 4530 ms | 70812 KB | Output is correct |
40 | Correct | 5573 ms | 70812 KB | Output is correct |
41 | Correct | 5635 ms | 70812 KB | Output is correct |
42 | Correct | 6077 ms | 70812 KB | Output is correct |
43 | Correct | 6064 ms | 70812 KB | Output is correct |
44 | Correct | 5788 ms | 70812 KB | Output is correct |
45 | Correct | 4123 ms | 70812 KB | Output is correct |
46 | Correct | 6202 ms | 70812 KB | Output is correct |
47 | Correct | 6000 ms | 70812 KB | Output is correct |
48 | Correct | 6045 ms | 70812 KB | Output is correct |
49 | Correct | 6557 ms | 70812 KB | Output is correct |
50 | Correct | 6568 ms | 70812 KB | Output is correct |
51 | Correct | 6866 ms | 70812 KB | Output is correct |
52 | Correct | 6812 ms | 70812 KB | Output is correct |
53 | Correct | 6834 ms | 70812 KB | Output is correct |
54 | Correct | 7659 ms | 70812 KB | Output is correct |
55 | Correct | 8528 ms | 70812 KB | Output is correct |
56 | Correct | 7805 ms | 70812 KB | Output is correct |
57 | Correct | 8032 ms | 70812 KB | Output is correct |
58 | Correct | 6114 ms | 70812 KB | Output is correct |
59 | Correct | 5085 ms | 70812 KB | Output is correct |
60 | Correct | 4816 ms | 70812 KB | Output is correct |
61 | Correct | 5947 ms | 70812 KB | Output is correct |
62 | Correct | 6209 ms | 70812 KB | Output is correct |
63 | Correct | 5642 ms | 70812 KB | Output is correct |
64 | Correct | 2633 ms | 70812 KB | Output is correct |
65 | Correct | 3717 ms | 70812 KB | Output is correct |
66 | Correct | 4201 ms | 70812 KB | Output is correct |
67 | Correct | 6196 ms | 70812 KB | Output is correct |
68 | Correct | 6775 ms | 70812 KB | Output is correct |
69 | Correct | 6617 ms | 70812 KB | Output is correct |
70 | Correct | 6690 ms | 70812 KB | Output is correct |