# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
86093 |
2018-11-24T19:55:53 Z |
zubec |
Lottery (CEOI18_lot) |
C++14 |
|
835 ms |
9352 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int n, l, a[20010], dp[110][10010], pos[10010], b[110], c[110];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin >> n >> l;
for (int i = 1; i <= n; i++){
cin >> a[i];
a[i+n] = a[i];
}
int q;
cin >> q;
for (int i = 1; i <= q; i++){
cin >> b[i];
c[i] = b[i];
}
sort(c+1, c+q+1);
for (int i = 1; i <= q; i++){
pos[c[i]] = i;
}
pos[n+1] = q+1;
for (int i = n; i >= 0; i--){
if (pos[i] == 0)
pos[i] = pos[i+1];
}
int cnt = 0;
for (int sz = 1; sz <= n; sz++){
int curans = 0;
if (l+sz > n)
break;
for (int i = 1; i < l; i++){
if (a[i] != a[i+sz])
++curans;
}
for (int i = 1; i <= n; i++){
if (i+l-1+sz > n)
break;
if (i != 1 && a[i-1] != a[i+sz-1])
--curans;
if (a[i+l-1] != a[i+l-1+sz])
++curans;
//cout << sz << ' ' << i << ' ' << curans << endl;
/*if (curans <= 28 && i == 1){
cout << "kek " << curans << ' ' << pos[curans] << ' ' << pos[28] << endl;
}*/
++dp[pos[curans]][i];
++dp[pos[curans]][i+sz];
}
}
/*cout << cnt;
return 0;*/
for (int i = 1; i <= q; i++){
for (int j = 1; j <= n; j++)
dp[i][j] += dp[i-1][j];
}
for (int i = 1; i <= q; i++){
for (int j = 1; j <= n-l+1; j++){
cout << dp[pos[b[i]]][j] << ' ';
}
cout << "\n";
}
}
Compilation message
lot.cpp: In function 'int main()':
lot.cpp:32:9: warning: unused variable 'cnt' [-Wunused-variable]
int cnt = 0;
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
500 KB |
Output is correct |
3 |
Correct |
3 ms |
644 KB |
Output is correct |
4 |
Correct |
2 ms |
644 KB |
Output is correct |
5 |
Correct |
2 ms |
644 KB |
Output is correct |
6 |
Correct |
2 ms |
644 KB |
Output is correct |
7 |
Correct |
3 ms |
644 KB |
Output is correct |
8 |
Correct |
3 ms |
888 KB |
Output is correct |
9 |
Correct |
3 ms |
888 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
11 |
Correct |
3 ms |
888 KB |
Output is correct |
12 |
Correct |
3 ms |
984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
500 KB |
Output is correct |
3 |
Correct |
3 ms |
644 KB |
Output is correct |
4 |
Correct |
2 ms |
644 KB |
Output is correct |
5 |
Correct |
2 ms |
644 KB |
Output is correct |
6 |
Correct |
2 ms |
644 KB |
Output is correct |
7 |
Correct |
3 ms |
644 KB |
Output is correct |
8 |
Correct |
3 ms |
888 KB |
Output is correct |
9 |
Correct |
3 ms |
888 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
11 |
Correct |
3 ms |
888 KB |
Output is correct |
12 |
Correct |
3 ms |
984 KB |
Output is correct |
13 |
Correct |
13 ms |
984 KB |
Output is correct |
14 |
Correct |
9 ms |
1024 KB |
Output is correct |
15 |
Correct |
9 ms |
1024 KB |
Output is correct |
16 |
Correct |
13 ms |
1192 KB |
Output is correct |
17 |
Correct |
11 ms |
1192 KB |
Output is correct |
18 |
Correct |
17 ms |
1232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
444 ms |
1232 KB |
Output is correct |
2 |
Correct |
638 ms |
1232 KB |
Output is correct |
3 |
Correct |
291 ms |
1232 KB |
Output is correct |
4 |
Correct |
220 ms |
1232 KB |
Output is correct |
5 |
Correct |
73 ms |
1232 KB |
Output is correct |
6 |
Correct |
174 ms |
1232 KB |
Output is correct |
7 |
Correct |
75 ms |
1232 KB |
Output is correct |
8 |
Correct |
106 ms |
1232 KB |
Output is correct |
9 |
Correct |
173 ms |
1232 KB |
Output is correct |
10 |
Correct |
178 ms |
1232 KB |
Output is correct |
11 |
Correct |
18 ms |
1232 KB |
Output is correct |
12 |
Correct |
149 ms |
1232 KB |
Output is correct |
13 |
Correct |
117 ms |
1232 KB |
Output is correct |
14 |
Correct |
115 ms |
1232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
444 ms |
1232 KB |
Output is correct |
2 |
Correct |
638 ms |
1232 KB |
Output is correct |
3 |
Correct |
291 ms |
1232 KB |
Output is correct |
4 |
Correct |
220 ms |
1232 KB |
Output is correct |
5 |
Correct |
73 ms |
1232 KB |
Output is correct |
6 |
Correct |
174 ms |
1232 KB |
Output is correct |
7 |
Correct |
75 ms |
1232 KB |
Output is correct |
8 |
Correct |
106 ms |
1232 KB |
Output is correct |
9 |
Correct |
173 ms |
1232 KB |
Output is correct |
10 |
Correct |
178 ms |
1232 KB |
Output is correct |
11 |
Correct |
18 ms |
1232 KB |
Output is correct |
12 |
Correct |
149 ms |
1232 KB |
Output is correct |
13 |
Correct |
117 ms |
1232 KB |
Output is correct |
14 |
Correct |
115 ms |
1232 KB |
Output is correct |
15 |
Correct |
292 ms |
1232 KB |
Output is correct |
16 |
Correct |
162 ms |
1232 KB |
Output is correct |
17 |
Correct |
203 ms |
1232 KB |
Output is correct |
18 |
Correct |
199 ms |
1232 KB |
Output is correct |
19 |
Correct |
183 ms |
1232 KB |
Output is correct |
20 |
Correct |
202 ms |
1232 KB |
Output is correct |
21 |
Correct |
186 ms |
1232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
500 KB |
Output is correct |
3 |
Correct |
3 ms |
644 KB |
Output is correct |
4 |
Correct |
2 ms |
644 KB |
Output is correct |
5 |
Correct |
2 ms |
644 KB |
Output is correct |
6 |
Correct |
2 ms |
644 KB |
Output is correct |
7 |
Correct |
3 ms |
644 KB |
Output is correct |
8 |
Correct |
3 ms |
888 KB |
Output is correct |
9 |
Correct |
3 ms |
888 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
11 |
Correct |
3 ms |
888 KB |
Output is correct |
12 |
Correct |
3 ms |
984 KB |
Output is correct |
13 |
Correct |
13 ms |
984 KB |
Output is correct |
14 |
Correct |
9 ms |
1024 KB |
Output is correct |
15 |
Correct |
9 ms |
1024 KB |
Output is correct |
16 |
Correct |
13 ms |
1192 KB |
Output is correct |
17 |
Correct |
11 ms |
1192 KB |
Output is correct |
18 |
Correct |
17 ms |
1232 KB |
Output is correct |
19 |
Correct |
444 ms |
1232 KB |
Output is correct |
20 |
Correct |
638 ms |
1232 KB |
Output is correct |
21 |
Correct |
291 ms |
1232 KB |
Output is correct |
22 |
Correct |
220 ms |
1232 KB |
Output is correct |
23 |
Correct |
73 ms |
1232 KB |
Output is correct |
24 |
Correct |
174 ms |
1232 KB |
Output is correct |
25 |
Correct |
75 ms |
1232 KB |
Output is correct |
26 |
Correct |
106 ms |
1232 KB |
Output is correct |
27 |
Correct |
173 ms |
1232 KB |
Output is correct |
28 |
Correct |
178 ms |
1232 KB |
Output is correct |
29 |
Correct |
18 ms |
1232 KB |
Output is correct |
30 |
Correct |
149 ms |
1232 KB |
Output is correct |
31 |
Correct |
117 ms |
1232 KB |
Output is correct |
32 |
Correct |
115 ms |
1232 KB |
Output is correct |
33 |
Correct |
292 ms |
1232 KB |
Output is correct |
34 |
Correct |
162 ms |
1232 KB |
Output is correct |
35 |
Correct |
203 ms |
1232 KB |
Output is correct |
36 |
Correct |
199 ms |
1232 KB |
Output is correct |
37 |
Correct |
183 ms |
1232 KB |
Output is correct |
38 |
Correct |
202 ms |
1232 KB |
Output is correct |
39 |
Correct |
186 ms |
1232 KB |
Output is correct |
40 |
Correct |
695 ms |
2608 KB |
Output is correct |
41 |
Correct |
14 ms |
2608 KB |
Output is correct |
42 |
Correct |
207 ms |
2728 KB |
Output is correct |
43 |
Correct |
192 ms |
2728 KB |
Output is correct |
44 |
Correct |
187 ms |
2752 KB |
Output is correct |
45 |
Correct |
835 ms |
9108 KB |
Output is correct |
46 |
Correct |
24 ms |
9108 KB |
Output is correct |
47 |
Correct |
289 ms |
9352 KB |
Output is correct |
48 |
Correct |
253 ms |
9352 KB |
Output is correct |
49 |
Correct |
288 ms |
9352 KB |
Output is correct |