# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
795928 |
2023-07-27T22:50:46 Z |
parsadox2 |
Lottery (CEOI18_lot) |
C++14 |
|
921 ms |
8408 KB |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 5 , maxq = 1e2 + 5;
int ans[maxn][maxq] , las[maxn] , ar[maxn] , n , q , l , qry[maxn] , dp[maxn] , sum[maxn];
int solve(int fir)
{
int res = 0;
for(int i = 0 ; i < l ; i++)
{
//cout << fir << " " << i << " " << ar[fir + i] << " " << ar[n - l + i] << endl;
if(ar[fir + i] != ar[n - l + i])
res++;
}
//cout << res << endl;
return res;
}
signed main()
{
cin >> n >> l;
for(int i = 0 ; i < n ; i++)
cin >> ar[i];
cin >> q;
for(int i = 0 ; i < q ; i++)
cin >> qry[i];
for(int i = 0 ; i + l <= n ; i++)
{
las[i] = solve(i);
dp[i] = las[i];
//cout << n - l << " " << i << " " << las[i] << endl;
sum[dp[i]]++;
}
for(int i = 1 ; i <= l ; i++)
sum[i] += sum[i - 1];
for(int i = 0 ; i < q ; i++)
ans[n - l][i] = sum[qry[i]] - 1;
for(int i = n - l - 1 ; i > -1 ; i--)
{
for(int j = 0 ; j < n - l ; j++)
{
dp[j] = dp[j + 1];
if(ar[i + l] != ar[j + l])
dp[j]--;
if(ar[i] != ar[j])
dp[j]++;
//cout << i << " " << j << " " << dp[j] << endl;
}
dp[n - l] = las[i];
for(int j = 0 ; j <= l ; j++)
sum[j] = 0;
for(int j = 0 ; j <= n - l ; j++)
sum[dp[j]]++;
for(int j = 1 ; j <= l ; j++)
sum[j] += sum[j - 1];
for(int j = 0 ; j < q ; j++)
ans[i][j] = sum[qry[j]] - 1;
}
for(int i = 0 ; i < q ; i++)
{
for(int j = 0 ; j <= n - l ; j++)
cout << ans[j][i] << " ";
cout << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
284 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
312 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
284 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
312 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
18 ms |
1096 KB |
Output is correct |
14 |
Correct |
11 ms |
976 KB |
Output is correct |
15 |
Correct |
10 ms |
952 KB |
Output is correct |
16 |
Correct |
14 ms |
1108 KB |
Output is correct |
17 |
Correct |
13 ms |
1108 KB |
Output is correct |
18 |
Correct |
13 ms |
1096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
628 ms |
4496 KB |
Output is correct |
2 |
Correct |
867 ms |
4468 KB |
Output is correct |
3 |
Correct |
384 ms |
4516 KB |
Output is correct |
4 |
Correct |
308 ms |
4552 KB |
Output is correct |
5 |
Correct |
127 ms |
2508 KB |
Output is correct |
6 |
Correct |
290 ms |
4304 KB |
Output is correct |
7 |
Correct |
158 ms |
2480 KB |
Output is correct |
8 |
Correct |
230 ms |
3384 KB |
Output is correct |
9 |
Correct |
290 ms |
4512 KB |
Output is correct |
10 |
Correct |
318 ms |
4480 KB |
Output is correct |
11 |
Correct |
15 ms |
1140 KB |
Output is correct |
12 |
Correct |
150 ms |
3352 KB |
Output is correct |
13 |
Correct |
162 ms |
2896 KB |
Output is correct |
14 |
Correct |
155 ms |
2828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
628 ms |
4496 KB |
Output is correct |
2 |
Correct |
867 ms |
4468 KB |
Output is correct |
3 |
Correct |
384 ms |
4516 KB |
Output is correct |
4 |
Correct |
308 ms |
4552 KB |
Output is correct |
5 |
Correct |
127 ms |
2508 KB |
Output is correct |
6 |
Correct |
290 ms |
4304 KB |
Output is correct |
7 |
Correct |
158 ms |
2480 KB |
Output is correct |
8 |
Correct |
230 ms |
3384 KB |
Output is correct |
9 |
Correct |
290 ms |
4512 KB |
Output is correct |
10 |
Correct |
318 ms |
4480 KB |
Output is correct |
11 |
Correct |
15 ms |
1140 KB |
Output is correct |
12 |
Correct |
150 ms |
3352 KB |
Output is correct |
13 |
Correct |
162 ms |
2896 KB |
Output is correct |
14 |
Correct |
155 ms |
2828 KB |
Output is correct |
15 |
Correct |
284 ms |
4356 KB |
Output is correct |
16 |
Correct |
274 ms |
4332 KB |
Output is correct |
17 |
Correct |
326 ms |
4524 KB |
Output is correct |
18 |
Correct |
320 ms |
4532 KB |
Output is correct |
19 |
Correct |
309 ms |
4556 KB |
Output is correct |
20 |
Correct |
309 ms |
4580 KB |
Output is correct |
21 |
Correct |
334 ms |
4560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
284 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
312 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
18 ms |
1096 KB |
Output is correct |
14 |
Correct |
11 ms |
976 KB |
Output is correct |
15 |
Correct |
10 ms |
952 KB |
Output is correct |
16 |
Correct |
14 ms |
1108 KB |
Output is correct |
17 |
Correct |
13 ms |
1108 KB |
Output is correct |
18 |
Correct |
13 ms |
1096 KB |
Output is correct |
19 |
Correct |
628 ms |
4496 KB |
Output is correct |
20 |
Correct |
867 ms |
4468 KB |
Output is correct |
21 |
Correct |
384 ms |
4516 KB |
Output is correct |
22 |
Correct |
308 ms |
4552 KB |
Output is correct |
23 |
Correct |
127 ms |
2508 KB |
Output is correct |
24 |
Correct |
290 ms |
4304 KB |
Output is correct |
25 |
Correct |
158 ms |
2480 KB |
Output is correct |
26 |
Correct |
230 ms |
3384 KB |
Output is correct |
27 |
Correct |
290 ms |
4512 KB |
Output is correct |
28 |
Correct |
318 ms |
4480 KB |
Output is correct |
29 |
Correct |
15 ms |
1140 KB |
Output is correct |
30 |
Correct |
150 ms |
3352 KB |
Output is correct |
31 |
Correct |
162 ms |
2896 KB |
Output is correct |
32 |
Correct |
155 ms |
2828 KB |
Output is correct |
33 |
Correct |
284 ms |
4356 KB |
Output is correct |
34 |
Correct |
274 ms |
4332 KB |
Output is correct |
35 |
Correct |
326 ms |
4524 KB |
Output is correct |
36 |
Correct |
320 ms |
4532 KB |
Output is correct |
37 |
Correct |
309 ms |
4556 KB |
Output is correct |
38 |
Correct |
309 ms |
4580 KB |
Output is correct |
39 |
Correct |
334 ms |
4560 KB |
Output is correct |
40 |
Correct |
871 ms |
5380 KB |
Output is correct |
41 |
Correct |
31 ms |
852 KB |
Output is correct |
42 |
Correct |
243 ms |
5288 KB |
Output is correct |
43 |
Correct |
307 ms |
4768 KB |
Output is correct |
44 |
Correct |
309 ms |
4888 KB |
Output is correct |
45 |
Correct |
921 ms |
8344 KB |
Output is correct |
46 |
Correct |
35 ms |
1284 KB |
Output is correct |
47 |
Correct |
348 ms |
8408 KB |
Output is correct |
48 |
Correct |
351 ms |
6468 KB |
Output is correct |
49 |
Correct |
352 ms |
7204 KB |
Output is correct |