# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
126004 | 2019-07-06T17:33:03 Z | Runtime_error_ | Lottery (CEOI18_lot) | C++14 | 671 ms | 8696 KB |
#include <bits/stdc++.h> using namespace std; const int N=1e4+9,Q=109; int n,l,q,a[N],id[N],ans[N][Q],where[N],tmp[N],pre[N]; pair<int,int> query[N]; int main(){ scanf("%d%d",&n,&l); for(int i=1;i<=n;i++) scanf("%d",a+i); scanf("%d",&q); for(int i=1;i<=q;i++) scanf("%d",&query[i].first),query[i].second = i; sort(query+1,query+1+q); for(int i=1;i<=q;i++) id[ query[i].second ] = i; for(int i=0;i<=l;i++){ where[i] = q+1; for(int j=1;j<=q;j++){ if(query[j].first >= i){ where[i] = j; break; } } } //tmp[i][j] = a[i]!=a[i+j] for(int j=1;j<=n-l+1;j++){ memset(pre,0,sizeof(pre)); memset(tmp,0,sizeof(tmp)); for(int i=1;i+j<=n;i++) tmp[i] = (a[i]!=a[i+j]),pre[i] = pre[i-1] +tmp[i]; for(int i=1;i+j+l-1<=n;i++){ int diff=pre[i+l-1]-pre[i-1]; ans[i][ where[diff] ]++; ans[i+j][where[diff]]++; } } for(int i=1;i<=n;i++) for(int j=1;j<=q;j++) ans[i][j]+=ans[i][j-1]; for(int i=1;i<=q;i++) for(int j=1;j<=n-l+1;j++) cout<<ans[j][id[i]]<<(j==n-l+1?'\n':' '); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 3 ms | 504 KB | Output is correct |
3 | Correct | 3 ms | 504 KB | Output is correct |
4 | Correct | 3 ms | 504 KB | Output is correct |
5 | Correct | 3 ms | 504 KB | Output is correct |
6 | Correct | 3 ms | 504 KB | Output is correct |
7 | Correct | 3 ms | 504 KB | Output is correct |
8 | Correct | 3 ms | 508 KB | Output is correct |
9 | Correct | 3 ms | 504 KB | Output is correct |
10 | Correct | 4 ms | 504 KB | Output is correct |
11 | Correct | 4 ms | 504 KB | Output is correct |
12 | Correct | 4 ms | 632 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 3 ms | 504 KB | Output is correct |
3 | Correct | 3 ms | 504 KB | Output is correct |
4 | Correct | 3 ms | 504 KB | Output is correct |
5 | Correct | 3 ms | 504 KB | Output is correct |
6 | Correct | 3 ms | 504 KB | Output is correct |
7 | Correct | 3 ms | 504 KB | Output is correct |
8 | Correct | 3 ms | 508 KB | Output is correct |
9 | Correct | 3 ms | 504 KB | Output is correct |
10 | Correct | 4 ms | 504 KB | Output is correct |
11 | Correct | 4 ms | 504 KB | Output is correct |
12 | Correct | 4 ms | 632 KB | Output is correct |
13 | Correct | 29 ms | 1276 KB | Output is correct |
14 | Correct | 20 ms | 1272 KB | Output is correct |
15 | Correct | 18 ms | 1272 KB | Output is correct |
16 | Correct | 28 ms | 1436 KB | Output is correct |
17 | Correct | 25 ms | 1400 KB | Output is correct |
18 | Correct | 25 ms | 1400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 511 ms | 4856 KB | Output is correct |
2 | Correct | 526 ms | 4776 KB | Output is correct |
3 | Correct | 528 ms | 4856 KB | Output is correct |
4 | Correct | 509 ms | 4856 KB | Output is correct |
5 | Correct | 178 ms | 4856 KB | Output is correct |
6 | Correct | 463 ms | 4844 KB | Output is correct |
7 | Correct | 188 ms | 4856 KB | Output is correct |
8 | Correct | 301 ms | 4828 KB | Output is correct |
9 | Correct | 496 ms | 4856 KB | Output is correct |
10 | Correct | 496 ms | 4856 KB | Output is correct |
11 | Correct | 32 ms | 1656 KB | Output is correct |
12 | Correct | 297 ms | 4344 KB | Output is correct |
13 | Correct | 245 ms | 4856 KB | Output is correct |
14 | Correct | 234 ms | 4856 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 511 ms | 4856 KB | Output is correct |
2 | Correct | 526 ms | 4776 KB | Output is correct |
3 | Correct | 528 ms | 4856 KB | Output is correct |
4 | Correct | 509 ms | 4856 KB | Output is correct |
5 | Correct | 178 ms | 4856 KB | Output is correct |
6 | Correct | 463 ms | 4844 KB | Output is correct |
7 | Correct | 188 ms | 4856 KB | Output is correct |
8 | Correct | 301 ms | 4828 KB | Output is correct |
9 | Correct | 496 ms | 4856 KB | Output is correct |
10 | Correct | 496 ms | 4856 KB | Output is correct |
11 | Correct | 32 ms | 1656 KB | Output is correct |
12 | Correct | 297 ms | 4344 KB | Output is correct |
13 | Correct | 245 ms | 4856 KB | Output is correct |
14 | Correct | 234 ms | 4856 KB | Output is correct |
15 | Correct | 491 ms | 4856 KB | Output is correct |
16 | Correct | 437 ms | 4828 KB | Output is correct |
17 | Correct | 513 ms | 4856 KB | Output is correct |
18 | Correct | 510 ms | 4828 KB | Output is correct |
19 | Correct | 501 ms | 4856 KB | Output is correct |
20 | Correct | 517 ms | 4856 KB | Output is correct |
21 | Correct | 507 ms | 4848 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 3 ms | 504 KB | Output is correct |
3 | Correct | 3 ms | 504 KB | Output is correct |
4 | Correct | 3 ms | 504 KB | Output is correct |
5 | Correct | 3 ms | 504 KB | Output is correct |
6 | Correct | 3 ms | 504 KB | Output is correct |
7 | Correct | 3 ms | 504 KB | Output is correct |
8 | Correct | 3 ms | 508 KB | Output is correct |
9 | Correct | 3 ms | 504 KB | Output is correct |
10 | Correct | 4 ms | 504 KB | Output is correct |
11 | Correct | 4 ms | 504 KB | Output is correct |
12 | Correct | 4 ms | 632 KB | Output is correct |
13 | Correct | 29 ms | 1276 KB | Output is correct |
14 | Correct | 20 ms | 1272 KB | Output is correct |
15 | Correct | 18 ms | 1272 KB | Output is correct |
16 | Correct | 28 ms | 1436 KB | Output is correct |
17 | Correct | 25 ms | 1400 KB | Output is correct |
18 | Correct | 25 ms | 1400 KB | Output is correct |
19 | Correct | 511 ms | 4856 KB | Output is correct |
20 | Correct | 526 ms | 4776 KB | Output is correct |
21 | Correct | 528 ms | 4856 KB | Output is correct |
22 | Correct | 509 ms | 4856 KB | Output is correct |
23 | Correct | 178 ms | 4856 KB | Output is correct |
24 | Correct | 463 ms | 4844 KB | Output is correct |
25 | Correct | 188 ms | 4856 KB | Output is correct |
26 | Correct | 301 ms | 4828 KB | Output is correct |
27 | Correct | 496 ms | 4856 KB | Output is correct |
28 | Correct | 496 ms | 4856 KB | Output is correct |
29 | Correct | 32 ms | 1656 KB | Output is correct |
30 | Correct | 297 ms | 4344 KB | Output is correct |
31 | Correct | 245 ms | 4856 KB | Output is correct |
32 | Correct | 234 ms | 4856 KB | Output is correct |
33 | Correct | 491 ms | 4856 KB | Output is correct |
34 | Correct | 437 ms | 4828 KB | Output is correct |
35 | Correct | 513 ms | 4856 KB | Output is correct |
36 | Correct | 510 ms | 4828 KB | Output is correct |
37 | Correct | 501 ms | 4856 KB | Output is correct |
38 | Correct | 517 ms | 4856 KB | Output is correct |
39 | Correct | 507 ms | 4848 KB | Output is correct |
40 | Correct | 546 ms | 5540 KB | Output is correct |
41 | Correct | 31 ms | 4856 KB | Output is correct |
42 | Correct | 529 ms | 5540 KB | Output is correct |
43 | Correct | 496 ms | 5240 KB | Output is correct |
44 | Correct | 506 ms | 5432 KB | Output is correct |
45 | Correct | 629 ms | 8696 KB | Output is correct |
46 | Correct | 41 ms | 5204 KB | Output is correct |
47 | Correct | 667 ms | 8696 KB | Output is correct |
48 | Correct | 640 ms | 6992 KB | Output is correct |
49 | Correct | 671 ms | 7744 KB | Output is correct |