#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
const int inf = 3e5;
struct ST{
vector<int> a;
int n;
ST(int ns){
n = ns;
a.resize(n + 1);
}
void upd(int p, int x){
p++;
a[p] += x;
}
int get(){
int out = 0;
for (int i = 1; i <= n; i++){
out = max(out, a[i]);
}
return out;
}
};
int minimumInstructions(int n, int m, int k, vector<int> x, vector<int> A, vector<vector<int>> B){
vector<int> d[k];
for (int i = 0; i < m; i++){
for (int j: B[i]){
d[j].pb(i);
}
}
vector<bool> gd(n);
int i = 0, j = 0;
ST T(inf);
while (i < n){
while (j < n){
for (int f: d[x[j]]){
T.upd(f - j + n, 1);
T.upd(f - j + (m + n), 1);
}
if (T.get() != (j - i + 1)){
for (int f: d[x[j]]){
T.upd(f - j + n, -1);
T.upd(f - j + (m + n), -1);
}
break;
}
j++;
}
for (int f = i; f <= j - m; f++) gd[f] = 1;
for (int f: d[x[i]]){
T.upd(f - i + n, -1);
T.upd(f - i + (m + n), -1);
}
i++;
}
int mx = -1, t = -1, out = 0;
for (int i = 0; i < n; i++){
if (gd[i]) t = i;
if (i == (mx + 1)){
if (t == -1) return -1;
mx = t + m - 1;
t = -1;
out++;
}
}
return out;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1360 KB |
Output is correct |
2 |
Correct |
2 ms |
1532 KB |
Output is correct |
3 |
Correct |
2 ms |
1360 KB |
Output is correct |
4 |
Correct |
2 ms |
1360 KB |
Output is correct |
5 |
Correct |
2 ms |
1360 KB |
Output is correct |
6 |
Correct |
2 ms |
1360 KB |
Output is correct |
7 |
Correct |
197 ms |
1360 KB |
Output is correct |
8 |
Correct |
203 ms |
1360 KB |
Output is correct |
9 |
Correct |
219 ms |
1360 KB |
Output is correct |
10 |
Correct |
221 ms |
1360 KB |
Output is correct |
11 |
Correct |
217 ms |
1360 KB |
Output is correct |
12 |
Correct |
212 ms |
1360 KB |
Output is correct |
13 |
Correct |
147 ms |
3920 KB |
Output is correct |
14 |
Correct |
151 ms |
3920 KB |
Output is correct |
15 |
Correct |
153 ms |
4088 KB |
Output is correct |
16 |
Correct |
127 ms |
3920 KB |
Output is correct |
17 |
Correct |
126 ms |
3920 KB |
Output is correct |
18 |
Correct |
131 ms |
3920 KB |
Output is correct |
19 |
Correct |
198 ms |
3920 KB |
Output is correct |
20 |
Correct |
198 ms |
3920 KB |
Output is correct |
21 |
Correct |
202 ms |
3920 KB |
Output is correct |
22 |
Correct |
238 ms |
8272 KB |
Output is correct |
23 |
Correct |
213 ms |
7760 KB |
Output is correct |
24 |
Correct |
216 ms |
7760 KB |
Output is correct |
25 |
Execution timed out |
1551 ms |
1616 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1360 KB |
Output is correct |
2 |
Correct |
2 ms |
1532 KB |
Output is correct |
3 |
Correct |
2 ms |
1360 KB |
Output is correct |
4 |
Correct |
2 ms |
1360 KB |
Output is correct |
5 |
Correct |
2 ms |
1360 KB |
Output is correct |
6 |
Correct |
2 ms |
1360 KB |
Output is correct |
7 |
Correct |
197 ms |
1360 KB |
Output is correct |
8 |
Correct |
203 ms |
1360 KB |
Output is correct |
9 |
Correct |
219 ms |
1360 KB |
Output is correct |
10 |
Correct |
221 ms |
1360 KB |
Output is correct |
11 |
Correct |
217 ms |
1360 KB |
Output is correct |
12 |
Correct |
212 ms |
1360 KB |
Output is correct |
13 |
Correct |
147 ms |
3920 KB |
Output is correct |
14 |
Correct |
151 ms |
3920 KB |
Output is correct |
15 |
Correct |
153 ms |
4088 KB |
Output is correct |
16 |
Correct |
127 ms |
3920 KB |
Output is correct |
17 |
Correct |
126 ms |
3920 KB |
Output is correct |
18 |
Correct |
131 ms |
3920 KB |
Output is correct |
19 |
Correct |
198 ms |
3920 KB |
Output is correct |
20 |
Correct |
198 ms |
3920 KB |
Output is correct |
21 |
Correct |
202 ms |
3920 KB |
Output is correct |
22 |
Correct |
4 ms |
1360 KB |
Output is correct |
23 |
Correct |
3 ms |
1360 KB |
Output is correct |
24 |
Correct |
3 ms |
1360 KB |
Output is correct |
25 |
Correct |
2 ms |
1360 KB |
Output is correct |
26 |
Correct |
2 ms |
1360 KB |
Output is correct |
27 |
Correct |
110 ms |
1360 KB |
Output is correct |
28 |
Correct |
119 ms |
1360 KB |
Output is correct |
29 |
Correct |
101 ms |
1360 KB |
Output is correct |
30 |
Correct |
137 ms |
1616 KB |
Output is correct |
31 |
Correct |
176 ms |
1360 KB |
Output is correct |
32 |
Correct |
146 ms |
1616 KB |
Output is correct |
33 |
Correct |
117 ms |
3420 KB |
Output is correct |
34 |
Correct |
145 ms |
2896 KB |
Output is correct |
35 |
Correct |
110 ms |
2896 KB |
Output is correct |
36 |
Correct |
104 ms |
3920 KB |
Output is correct |
37 |
Correct |
80 ms |
3408 KB |
Output is correct |
38 |
Correct |
123 ms |
3664 KB |
Output is correct |
39 |
Correct |
120 ms |
1616 KB |
Output is correct |
40 |
Correct |
125 ms |
3408 KB |
Output is correct |
41 |
Correct |
83 ms |
1780 KB |
Output is correct |
42 |
Correct |
172 ms |
3664 KB |
Output is correct |
43 |
Correct |
137 ms |
3664 KB |
Output is correct |
44 |
Correct |
200 ms |
1528 KB |
Output is correct |
45 |
Correct |
212 ms |
1616 KB |
Output is correct |
46 |
Correct |
217 ms |
1360 KB |
Output is correct |
47 |
Correct |
198 ms |
1616 KB |
Output is correct |
48 |
Correct |
203 ms |
1360 KB |
Output is correct |
49 |
Correct |
199 ms |
1616 KB |
Output is correct |
50 |
Correct |
158 ms |
3920 KB |
Output is correct |
51 |
Correct |
148 ms |
3920 KB |
Output is correct |
52 |
Correct |
146 ms |
3920 KB |
Output is correct |
53 |
Correct |
132 ms |
3920 KB |
Output is correct |
54 |
Correct |
138 ms |
3920 KB |
Output is correct |
55 |
Correct |
153 ms |
3920 KB |
Output is correct |
56 |
Correct |
206 ms |
3920 KB |
Output is correct |
57 |
Correct |
143 ms |
1616 KB |
Output is correct |
58 |
Correct |
203 ms |
3920 KB |
Output is correct |
59 |
Correct |
151 ms |
1616 KB |
Output is correct |
60 |
Correct |
202 ms |
3936 KB |
Output is correct |
61 |
Correct |
122 ms |
1616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1360 KB |
Output is correct |
2 |
Correct |
3 ms |
1360 KB |
Output is correct |
3 |
Correct |
1 ms |
1360 KB |
Output is correct |
4 |
Correct |
2 ms |
1532 KB |
Output is correct |
5 |
Correct |
2 ms |
1360 KB |
Output is correct |
6 |
Correct |
2 ms |
1360 KB |
Output is correct |
7 |
Correct |
2 ms |
1360 KB |
Output is correct |
8 |
Correct |
2 ms |
1360 KB |
Output is correct |
9 |
Correct |
197 ms |
1360 KB |
Output is correct |
10 |
Correct |
203 ms |
1360 KB |
Output is correct |
11 |
Correct |
219 ms |
1360 KB |
Output is correct |
12 |
Correct |
221 ms |
1360 KB |
Output is correct |
13 |
Correct |
217 ms |
1360 KB |
Output is correct |
14 |
Correct |
212 ms |
1360 KB |
Output is correct |
15 |
Correct |
147 ms |
3920 KB |
Output is correct |
16 |
Correct |
151 ms |
3920 KB |
Output is correct |
17 |
Correct |
153 ms |
4088 KB |
Output is correct |
18 |
Correct |
127 ms |
3920 KB |
Output is correct |
19 |
Correct |
126 ms |
3920 KB |
Output is correct |
20 |
Correct |
131 ms |
3920 KB |
Output is correct |
21 |
Correct |
198 ms |
3920 KB |
Output is correct |
22 |
Correct |
198 ms |
3920 KB |
Output is correct |
23 |
Correct |
202 ms |
3920 KB |
Output is correct |
24 |
Correct |
238 ms |
8272 KB |
Output is correct |
25 |
Correct |
213 ms |
7760 KB |
Output is correct |
26 |
Correct |
216 ms |
7760 KB |
Output is correct |
27 |
Correct |
3 ms |
1360 KB |
Output is correct |
28 |
Correct |
2 ms |
1360 KB |
Output is correct |
29 |
Correct |
2 ms |
1360 KB |
Output is correct |
30 |
Correct |
110 ms |
1360 KB |
Output is correct |
31 |
Correct |
119 ms |
1360 KB |
Output is correct |
32 |
Correct |
101 ms |
1360 KB |
Output is correct |
33 |
Correct |
137 ms |
1616 KB |
Output is correct |
34 |
Correct |
176 ms |
1360 KB |
Output is correct |
35 |
Correct |
146 ms |
1616 KB |
Output is correct |
36 |
Correct |
117 ms |
3420 KB |
Output is correct |
37 |
Correct |
145 ms |
2896 KB |
Output is correct |
38 |
Correct |
110 ms |
2896 KB |
Output is correct |
39 |
Correct |
104 ms |
3920 KB |
Output is correct |
40 |
Correct |
80 ms |
3408 KB |
Output is correct |
41 |
Correct |
123 ms |
3664 KB |
Output is correct |
42 |
Correct |
120 ms |
1616 KB |
Output is correct |
43 |
Correct |
125 ms |
3408 KB |
Output is correct |
44 |
Correct |
83 ms |
1780 KB |
Output is correct |
45 |
Correct |
172 ms |
3664 KB |
Output is correct |
46 |
Correct |
137 ms |
3664 KB |
Output is correct |
47 |
Correct |
200 ms |
1528 KB |
Output is correct |
48 |
Correct |
212 ms |
1616 KB |
Output is correct |
49 |
Correct |
217 ms |
1360 KB |
Output is correct |
50 |
Correct |
198 ms |
1616 KB |
Output is correct |
51 |
Correct |
203 ms |
1360 KB |
Output is correct |
52 |
Correct |
199 ms |
1616 KB |
Output is correct |
53 |
Correct |
158 ms |
3920 KB |
Output is correct |
54 |
Correct |
148 ms |
3920 KB |
Output is correct |
55 |
Correct |
146 ms |
3920 KB |
Output is correct |
56 |
Correct |
132 ms |
3920 KB |
Output is correct |
57 |
Correct |
138 ms |
3920 KB |
Output is correct |
58 |
Correct |
153 ms |
3920 KB |
Output is correct |
59 |
Correct |
206 ms |
3920 KB |
Output is correct |
60 |
Correct |
143 ms |
1616 KB |
Output is correct |
61 |
Correct |
203 ms |
3920 KB |
Output is correct |
62 |
Correct |
151 ms |
1616 KB |
Output is correct |
63 |
Correct |
202 ms |
3936 KB |
Output is correct |
64 |
Correct |
122 ms |
1616 KB |
Output is correct |
65 |
Correct |
52 ms |
1616 KB |
Output is correct |
66 |
Correct |
174 ms |
1360 KB |
Output is correct |
67 |
Correct |
145 ms |
1616 KB |
Output is correct |
68 |
Correct |
171 ms |
1616 KB |
Output is correct |
69 |
Correct |
131 ms |
1616 KB |
Output is correct |
70 |
Correct |
111 ms |
3664 KB |
Output is correct |
71 |
Correct |
112 ms |
3576 KB |
Output is correct |
72 |
Correct |
129 ms |
3152 KB |
Output is correct |
73 |
Correct |
148 ms |
3152 KB |
Output is correct |
74 |
Correct |
103 ms |
3408 KB |
Output is correct |
75 |
Correct |
75 ms |
3920 KB |
Output is correct |
76 |
Correct |
128 ms |
5712 KB |
Output is correct |
77 |
Correct |
155 ms |
6728 KB |
Output is correct |
78 |
Correct |
156 ms |
8016 KB |
Output is correct |
79 |
Correct |
126 ms |
1616 KB |
Output is correct |
80 |
Correct |
119 ms |
1784 KB |
Output is correct |
81 |
Correct |
119 ms |
1616 KB |
Output is correct |
82 |
Correct |
122 ms |
1616 KB |
Output is correct |
83 |
Correct |
119 ms |
1616 KB |
Output is correct |
84 |
Correct |
124 ms |
4176 KB |
Output is correct |
85 |
Correct |
124 ms |
4176 KB |
Output is correct |
86 |
Correct |
134 ms |
4176 KB |
Output is correct |
87 |
Correct |
144 ms |
4176 KB |
Output is correct |
88 |
Correct |
143 ms |
4176 KB |
Output is correct |
89 |
Correct |
138 ms |
4176 KB |
Output is correct |
90 |
Correct |
219 ms |
7504 KB |
Output is correct |
91 |
Correct |
226 ms |
7504 KB |
Output is correct |
92 |
Correct |
218 ms |
7504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1360 KB |
Output is correct |
2 |
Correct |
3 ms |
1360 KB |
Output is correct |
3 |
Correct |
1 ms |
1360 KB |
Output is correct |
4 |
Correct |
2 ms |
1532 KB |
Output is correct |
5 |
Correct |
2 ms |
1360 KB |
Output is correct |
6 |
Correct |
2 ms |
1360 KB |
Output is correct |
7 |
Correct |
2 ms |
1360 KB |
Output is correct |
8 |
Correct |
2 ms |
1360 KB |
Output is correct |
9 |
Correct |
197 ms |
1360 KB |
Output is correct |
10 |
Correct |
203 ms |
1360 KB |
Output is correct |
11 |
Correct |
219 ms |
1360 KB |
Output is correct |
12 |
Correct |
221 ms |
1360 KB |
Output is correct |
13 |
Correct |
217 ms |
1360 KB |
Output is correct |
14 |
Correct |
212 ms |
1360 KB |
Output is correct |
15 |
Correct |
147 ms |
3920 KB |
Output is correct |
16 |
Correct |
151 ms |
3920 KB |
Output is correct |
17 |
Correct |
153 ms |
4088 KB |
Output is correct |
18 |
Correct |
127 ms |
3920 KB |
Output is correct |
19 |
Correct |
126 ms |
3920 KB |
Output is correct |
20 |
Correct |
131 ms |
3920 KB |
Output is correct |
21 |
Correct |
198 ms |
3920 KB |
Output is correct |
22 |
Correct |
198 ms |
3920 KB |
Output is correct |
23 |
Correct |
202 ms |
3920 KB |
Output is correct |
24 |
Correct |
238 ms |
8272 KB |
Output is correct |
25 |
Correct |
213 ms |
7760 KB |
Output is correct |
26 |
Correct |
216 ms |
7760 KB |
Output is correct |
27 |
Execution timed out |
1551 ms |
1616 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1360 KB |
Output is correct |
2 |
Correct |
3 ms |
1360 KB |
Output is correct |
3 |
Correct |
1 ms |
1360 KB |
Output is correct |
4 |
Correct |
2 ms |
1532 KB |
Output is correct |
5 |
Correct |
2 ms |
1360 KB |
Output is correct |
6 |
Correct |
2 ms |
1360 KB |
Output is correct |
7 |
Correct |
2 ms |
1360 KB |
Output is correct |
8 |
Correct |
2 ms |
1360 KB |
Output is correct |
9 |
Correct |
197 ms |
1360 KB |
Output is correct |
10 |
Correct |
203 ms |
1360 KB |
Output is correct |
11 |
Correct |
219 ms |
1360 KB |
Output is correct |
12 |
Correct |
221 ms |
1360 KB |
Output is correct |
13 |
Correct |
217 ms |
1360 KB |
Output is correct |
14 |
Correct |
212 ms |
1360 KB |
Output is correct |
15 |
Correct |
147 ms |
3920 KB |
Output is correct |
16 |
Correct |
151 ms |
3920 KB |
Output is correct |
17 |
Correct |
153 ms |
4088 KB |
Output is correct |
18 |
Correct |
127 ms |
3920 KB |
Output is correct |
19 |
Correct |
126 ms |
3920 KB |
Output is correct |
20 |
Correct |
131 ms |
3920 KB |
Output is correct |
21 |
Correct |
198 ms |
3920 KB |
Output is correct |
22 |
Correct |
198 ms |
3920 KB |
Output is correct |
23 |
Correct |
202 ms |
3920 KB |
Output is correct |
24 |
Correct |
238 ms |
8272 KB |
Output is correct |
25 |
Correct |
213 ms |
7760 KB |
Output is correct |
26 |
Correct |
216 ms |
7760 KB |
Output is correct |
27 |
Execution timed out |
1551 ms |
1616 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |