# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
417816 | 2021-06-04T10:53:34 Z | 반딧불(#7603) | Parking Problem (innopolis2021_final_A) | C++17 | 160 ms | 1940 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int t; int n, q; bool arr[100002]; int que[100002]; vector<int> vec; bool able(int x){ int c1 = 1, c2 = 0; for(int i=1; i<=x; i++){ if(que[i] == 1) c1++; else c2++; } vector<int> v = vec; for(auto &x: v) if(x == 1) x = 2; for(auto &x: v){ if(x%2 == 1 && c2){ c2--; x -= 3; } } priority_queue<int> pq; for(auto x: v) pq.push(x); while(c2 && !pq.empty()){ int tmp = pq.top(); pq.pop(); if(tmp >= 6 && c2 >= 2){ if(tmp > 6) pq.push(tmp - 6); c2 -= 2; } else{ if(tmp > 3) pq.push(tmp - 3); c2--; } } v.clear(); while(!pq.empty()){ v.push_back(pq.top()); pq.pop(); } for(auto &x: v){ c1 -= (x+1) / 2; } return c1 <= 0; } int main(){ scanf("%d", &t); while(t--){ { string str; cin >> str; n = (int)str.size(); for(int i=1; i<=n; i++) arr[i] = (str[i-1] == 'X'); cin >> str; q = (int)str.size(); for(int i=1; i<=q; i++) que[i] = (str[i-1] == 'C') ? 2 : 1; } vec.clear(); int cnt = 0; for(int i=1; i<=n+1; i++){ if(i<=n && !arr[i]) cnt++; else{ if(cnt >= 2) vec.push_back(cnt-1); cnt = 0; } } int MIN = 0, MAX = q, ans = -1; while(MIN <= MAX){ int MID = (MIN + MAX) / 2; if(able(MID)){ ans = MID; MIN = MID+1; } else MAX = MID-1; } for(int i=0; i<=q; i++) printf("%c", ans >= i ? 'Y' : 'N'); puts(""); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 856 KB | Output is correct |
2 | Correct | 50 ms | 452 KB | Output is correct |
3 | Correct | 148 ms | 752 KB | Output is correct |
4 | Correct | 41 ms | 1032 KB | Output is correct |
5 | Correct | 49 ms | 468 KB | Output is correct |
6 | Correct | 45 ms | 1056 KB | Output is correct |
7 | Correct | 55 ms | 456 KB | Output is correct |
8 | Correct | 151 ms | 580 KB | Output is correct |
9 | Correct | 42 ms | 832 KB | Output is correct |
10 | Correct | 51 ms | 536 KB | Output is correct |
11 | Correct | 150 ms | 608 KB | Output is correct |
12 | Correct | 42 ms | 1024 KB | Output is correct |
13 | Correct | 54 ms | 472 KB | Output is correct |
14 | Correct | 153 ms | 852 KB | Output is correct |
15 | Correct | 151 ms | 564 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 1028 KB | Output is correct |
2 | Correct | 49 ms | 500 KB | Output is correct |
3 | Correct | 154 ms | 588 KB | Output is correct |
4 | Correct | 39 ms | 1016 KB | Output is correct |
5 | Correct | 49 ms | 540 KB | Output is correct |
6 | Correct | 35 ms | 968 KB | Output is correct |
7 | Correct | 52 ms | 460 KB | Output is correct |
8 | Correct | 155 ms | 724 KB | Output is correct |
9 | Correct | 49 ms | 1716 KB | Output is correct |
10 | Correct | 55 ms | 1228 KB | Output is correct |
11 | Correct | 155 ms | 1476 KB | Output is correct |
12 | Correct | 47 ms | 1680 KB | Output is correct |
13 | Correct | 55 ms | 1240 KB | Output is correct |
14 | Correct | 160 ms | 1480 KB | Output is correct |
15 | Correct | 137 ms | 1136 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 88 ms | 1048 KB | Output is correct |
2 | Correct | 72 ms | 580 KB | Output is correct |
3 | Correct | 61 ms | 608 KB | Output is correct |
4 | Correct | 65 ms | 436 KB | Output is correct |
5 | Correct | 76 ms | 452 KB | Output is correct |
6 | Correct | 97 ms | 540 KB | Output is correct |
7 | Correct | 125 ms | 584 KB | Output is correct |
8 | Correct | 158 ms | 576 KB | Output is correct |
9 | Correct | 138 ms | 524 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 856 KB | Output is correct |
2 | Correct | 50 ms | 452 KB | Output is correct |
3 | Correct | 148 ms | 752 KB | Output is correct |
4 | Correct | 41 ms | 1032 KB | Output is correct |
5 | Correct | 49 ms | 468 KB | Output is correct |
6 | Correct | 45 ms | 1056 KB | Output is correct |
7 | Correct | 55 ms | 456 KB | Output is correct |
8 | Correct | 151 ms | 580 KB | Output is correct |
9 | Correct | 42 ms | 832 KB | Output is correct |
10 | Correct | 51 ms | 536 KB | Output is correct |
11 | Correct | 150 ms | 608 KB | Output is correct |
12 | Correct | 42 ms | 1024 KB | Output is correct |
13 | Correct | 54 ms | 472 KB | Output is correct |
14 | Correct | 153 ms | 852 KB | Output is correct |
15 | Correct | 151 ms | 564 KB | Output is correct |
16 | Correct | 37 ms | 1028 KB | Output is correct |
17 | Correct | 49 ms | 500 KB | Output is correct |
18 | Correct | 154 ms | 588 KB | Output is correct |
19 | Correct | 39 ms | 1016 KB | Output is correct |
20 | Correct | 49 ms | 540 KB | Output is correct |
21 | Correct | 35 ms | 968 KB | Output is correct |
22 | Correct | 52 ms | 460 KB | Output is correct |
23 | Correct | 155 ms | 724 KB | Output is correct |
24 | Correct | 49 ms | 1716 KB | Output is correct |
25 | Correct | 55 ms | 1228 KB | Output is correct |
26 | Correct | 155 ms | 1476 KB | Output is correct |
27 | Correct | 47 ms | 1680 KB | Output is correct |
28 | Correct | 55 ms | 1240 KB | Output is correct |
29 | Correct | 160 ms | 1480 KB | Output is correct |
30 | Correct | 137 ms | 1136 KB | Output is correct |
31 | Correct | 88 ms | 1048 KB | Output is correct |
32 | Correct | 72 ms | 580 KB | Output is correct |
33 | Correct | 61 ms | 608 KB | Output is correct |
34 | Correct | 65 ms | 436 KB | Output is correct |
35 | Correct | 76 ms | 452 KB | Output is correct |
36 | Correct | 97 ms | 540 KB | Output is correct |
37 | Correct | 125 ms | 584 KB | Output is correct |
38 | Correct | 158 ms | 576 KB | Output is correct |
39 | Correct | 138 ms | 524 KB | Output is correct |
40 | Correct | 0 ms | 204 KB | Output is correct |
41 | Correct | 0 ms | 204 KB | Output is correct |
42 | Correct | 4 ms | 204 KB | Output is correct |
43 | Correct | 13 ms | 476 KB | Output is correct |
44 | Correct | 6 ms | 332 KB | Output is correct |
45 | Correct | 11 ms | 332 KB | Output is correct |
46 | Correct | 135 ms | 960 KB | Output is correct |
47 | Correct | 117 ms | 1940 KB | Output is correct |
48 | Correct | 104 ms | 1780 KB | Output is correct |
49 | Correct | 82 ms | 1716 KB | Output is correct |