# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1073980 |
2024-08-25T05:50:49 Z |
lftroq |
Lottery (CEOI18_lot) |
C++14 |
|
457 ms |
8376 KB |
#include <bits/stdc++.h>
#define endl '\n'
#define fi first
#define se second
#define sqrt sqrtl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,pii> piiii;
const int N=1e4+5;
const int Q=105;
int a[N],qu[Q],dp[N][Q],rev[N];
void solve()
{
int n,l,q;
cin >> n >> l;
for(int i=1;i<=n;i++) cin >> a[i];
cin >> q;
vector<int> v;
for(int i=1;i<=q;i++)
{
cin >> qu[i];
v.push_back(qu[i]);
}
v.push_back(0);v.push_back(N-1);
sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
for(int i=0;i<(int)v.size();i++) rev[v[i]]=i;
for(int len=1;len<=n-l;len++)
{
int x=1,y=len+1,d=0,p=0;
for(int i=1;i<=l;i++)
{
d+=(a[x+i-1]!=a[y+i-1]);
if(v[p]<d) p++;
}
// cout << len << ' ' << d << ":" << endl;
for(;y<=n-l+1;x++,y++)
{
dp[x][p]++;dp[y][p]++;
// cout << x << ' ' << y << ' ' << d << " " << p << endl;
d-=(a[x]!=a[y]);
if(v[p]>d) p--;
d+=(a[x+l]!=a[y+l]);
if(v[p]<d) p++;
}
// cout << "=============" << endl;
}
for(int i=1;i<=n;i++) for(int j=1;j<(int)v.size();j++) dp[i][j]+=dp[i][j-1];
for(int i=1;i<=q;i++)
{
for(int j=1;j<=n-l+1;j++) cout << dp[j][rev[qu[i]]] << ' ';
cout << endl;
}
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//freopen("hanhhhh.inp","r",stdin);
//freopen("hanhhhh.out","w",stdout);
int t=1;
//cin >> t;
while(t--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
11 ms |
1116 KB |
Output is correct |
14 |
Correct |
6 ms |
1116 KB |
Output is correct |
15 |
Correct |
6 ms |
1112 KB |
Output is correct |
16 |
Correct |
9 ms |
1372 KB |
Output is correct |
17 |
Correct |
8 ms |
1372 KB |
Output is correct |
18 |
Correct |
10 ms |
1372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
278 ms |
4604 KB |
Output is correct |
2 |
Correct |
221 ms |
4440 KB |
Output is correct |
3 |
Correct |
205 ms |
4584 KB |
Output is correct |
4 |
Correct |
204 ms |
4692 KB |
Output is correct |
5 |
Correct |
78 ms |
4596 KB |
Output is correct |
6 |
Correct |
186 ms |
4436 KB |
Output is correct |
7 |
Correct |
76 ms |
4580 KB |
Output is correct |
8 |
Correct |
123 ms |
4432 KB |
Output is correct |
9 |
Correct |
202 ms |
4456 KB |
Output is correct |
10 |
Correct |
206 ms |
4516 KB |
Output is correct |
11 |
Correct |
11 ms |
1628 KB |
Output is correct |
12 |
Correct |
124 ms |
4108 KB |
Output is correct |
13 |
Correct |
98 ms |
4432 KB |
Output is correct |
14 |
Correct |
99 ms |
4432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
278 ms |
4604 KB |
Output is correct |
2 |
Correct |
221 ms |
4440 KB |
Output is correct |
3 |
Correct |
205 ms |
4584 KB |
Output is correct |
4 |
Correct |
204 ms |
4692 KB |
Output is correct |
5 |
Correct |
78 ms |
4596 KB |
Output is correct |
6 |
Correct |
186 ms |
4436 KB |
Output is correct |
7 |
Correct |
76 ms |
4580 KB |
Output is correct |
8 |
Correct |
123 ms |
4432 KB |
Output is correct |
9 |
Correct |
202 ms |
4456 KB |
Output is correct |
10 |
Correct |
206 ms |
4516 KB |
Output is correct |
11 |
Correct |
11 ms |
1628 KB |
Output is correct |
12 |
Correct |
124 ms |
4108 KB |
Output is correct |
13 |
Correct |
98 ms |
4432 KB |
Output is correct |
14 |
Correct |
99 ms |
4432 KB |
Output is correct |
15 |
Correct |
202 ms |
4444 KB |
Output is correct |
16 |
Correct |
177 ms |
4432 KB |
Output is correct |
17 |
Correct |
214 ms |
4588 KB |
Output is correct |
18 |
Correct |
208 ms |
4556 KB |
Output is correct |
19 |
Correct |
208 ms |
4444 KB |
Output is correct |
20 |
Correct |
203 ms |
4692 KB |
Output is correct |
21 |
Correct |
207 ms |
4440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
11 ms |
1116 KB |
Output is correct |
14 |
Correct |
6 ms |
1116 KB |
Output is correct |
15 |
Correct |
6 ms |
1112 KB |
Output is correct |
16 |
Correct |
9 ms |
1372 KB |
Output is correct |
17 |
Correct |
8 ms |
1372 KB |
Output is correct |
18 |
Correct |
10 ms |
1372 KB |
Output is correct |
19 |
Correct |
278 ms |
4604 KB |
Output is correct |
20 |
Correct |
221 ms |
4440 KB |
Output is correct |
21 |
Correct |
205 ms |
4584 KB |
Output is correct |
22 |
Correct |
204 ms |
4692 KB |
Output is correct |
23 |
Correct |
78 ms |
4596 KB |
Output is correct |
24 |
Correct |
186 ms |
4436 KB |
Output is correct |
25 |
Correct |
76 ms |
4580 KB |
Output is correct |
26 |
Correct |
123 ms |
4432 KB |
Output is correct |
27 |
Correct |
202 ms |
4456 KB |
Output is correct |
28 |
Correct |
206 ms |
4516 KB |
Output is correct |
29 |
Correct |
11 ms |
1628 KB |
Output is correct |
30 |
Correct |
124 ms |
4108 KB |
Output is correct |
31 |
Correct |
98 ms |
4432 KB |
Output is correct |
32 |
Correct |
99 ms |
4432 KB |
Output is correct |
33 |
Correct |
202 ms |
4444 KB |
Output is correct |
34 |
Correct |
177 ms |
4432 KB |
Output is correct |
35 |
Correct |
214 ms |
4588 KB |
Output is correct |
36 |
Correct |
208 ms |
4556 KB |
Output is correct |
37 |
Correct |
208 ms |
4444 KB |
Output is correct |
38 |
Correct |
203 ms |
4692 KB |
Output is correct |
39 |
Correct |
207 ms |
4440 KB |
Output is correct |
40 |
Correct |
280 ms |
5328 KB |
Output is correct |
41 |
Correct |
14 ms |
4444 KB |
Output is correct |
42 |
Correct |
218 ms |
5328 KB |
Output is correct |
43 |
Correct |
201 ms |
4920 KB |
Output is correct |
44 |
Correct |
207 ms |
4944 KB |
Output is correct |
45 |
Correct |
457 ms |
8276 KB |
Output is correct |
46 |
Correct |
19 ms |
4956 KB |
Output is correct |
47 |
Correct |
243 ms |
8376 KB |
Output is correct |
48 |
Correct |
235 ms |
6484 KB |
Output is correct |
49 |
Correct |
234 ms |
7248 KB |
Output is correct |