# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
72891 |
2018-08-27T07:43:57 Z |
zscoder |
Lottery (CEOI18_lot) |
C++17 |
|
2265 ms |
13324 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 10011;
int dp[N];
int a[N];
void addrange(int l, int r)
{
l=max(l,0);
r=min(r,N-2);
dp[l]++; dp[r+1]--;
}
void reset()
{
memset(dp,0,sizeof(dp));
}
void push()
{
for(int i=1;i<N;i++)
{
dp[i]+=dp[i-1];
}
}
bool valid(int x, int n)
{
return (x>=0&&x<n);
}
vector<ii> queries;
int pref[11111];
int ans[111][11111];
int sorted[11111][111];
void solve(int n, int l, int d)
{
reset();
for(int i=0;i<n;i++)
{
if(valid(i+d,n)&&a[i]==a[i+d])
{
addrange(i-l+1,i);
}
}
push();
for(int i=0;i<=n-l;i++)
{
if(!valid(i+d,n-l+1)) continue;
int mx = pref[dp[i]];
mx--;
if(mx>=0)
{
sorted[i][mx]++;
}
}
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int n,l; cin>>n>>l;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int q; cin>>q;
for(int i=0;i<q;i++)
{
int d; cin>>d; d = l-d;
queries.pb(mp(d,i));
}
sort(queries.begin(),queries.end());
for(int i=0;i<q;i++)
{
pref[queries[i].fi]++;
}
for(int i=1;i<=n;i++)
{
pref[i]+=pref[i-1];
}
for(int d=-n;d<=n;d++)
{
if(d==0) continue;
solve(n,l,d);
}
for(int i=0;i<n;i++)
{
for(int j=q-1;j>=0;j--)
{
sorted[i][j]+=sorted[i][j+1];
}
for(int j=0;j<q;j++)
{
ans[queries[j].se][i] = sorted[i][j];
}
}
for(int i=0;i<q;i++)
{
for(int j=0;j<n-l+1;j++)
{
cout<<ans[i][j];
if(j+1<n-l+1) cout<<' ';
}
cout<<'\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
9 ms |
612 KB |
Output is correct |
3 |
Correct |
11 ms |
688 KB |
Output is correct |
4 |
Correct |
9 ms |
688 KB |
Output is correct |
5 |
Correct |
9 ms |
688 KB |
Output is correct |
6 |
Correct |
11 ms |
688 KB |
Output is correct |
7 |
Correct |
8 ms |
748 KB |
Output is correct |
8 |
Correct |
22 ms |
984 KB |
Output is correct |
9 |
Correct |
20 ms |
984 KB |
Output is correct |
10 |
Correct |
22 ms |
984 KB |
Output is correct |
11 |
Correct |
21 ms |
984 KB |
Output is correct |
12 |
Correct |
21 ms |
984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
9 ms |
612 KB |
Output is correct |
3 |
Correct |
11 ms |
688 KB |
Output is correct |
4 |
Correct |
9 ms |
688 KB |
Output is correct |
5 |
Correct |
9 ms |
688 KB |
Output is correct |
6 |
Correct |
11 ms |
688 KB |
Output is correct |
7 |
Correct |
8 ms |
748 KB |
Output is correct |
8 |
Correct |
22 ms |
984 KB |
Output is correct |
9 |
Correct |
20 ms |
984 KB |
Output is correct |
10 |
Correct |
22 ms |
984 KB |
Output is correct |
11 |
Correct |
21 ms |
984 KB |
Output is correct |
12 |
Correct |
21 ms |
984 KB |
Output is correct |
13 |
Correct |
175 ms |
1736 KB |
Output is correct |
14 |
Correct |
150 ms |
1900 KB |
Output is correct |
15 |
Correct |
140 ms |
1900 KB |
Output is correct |
16 |
Correct |
149 ms |
1904 KB |
Output is correct |
17 |
Correct |
140 ms |
1904 KB |
Output is correct |
18 |
Correct |
141 ms |
1904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2012 ms |
5428 KB |
Output is correct |
2 |
Correct |
1806 ms |
5428 KB |
Output is correct |
3 |
Correct |
1291 ms |
5428 KB |
Output is correct |
4 |
Correct |
1129 ms |
5428 KB |
Output is correct |
5 |
Correct |
1112 ms |
5428 KB |
Output is correct |
6 |
Correct |
1146 ms |
5428 KB |
Output is correct |
7 |
Correct |
1390 ms |
5428 KB |
Output is correct |
8 |
Correct |
1400 ms |
5428 KB |
Output is correct |
9 |
Correct |
1173 ms |
5548 KB |
Output is correct |
10 |
Correct |
1160 ms |
5548 KB |
Output is correct |
11 |
Correct |
225 ms |
5548 KB |
Output is correct |
12 |
Correct |
1012 ms |
5548 KB |
Output is correct |
13 |
Correct |
1006 ms |
5548 KB |
Output is correct |
14 |
Correct |
1154 ms |
5548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2012 ms |
5428 KB |
Output is correct |
2 |
Correct |
1806 ms |
5428 KB |
Output is correct |
3 |
Correct |
1291 ms |
5428 KB |
Output is correct |
4 |
Correct |
1129 ms |
5428 KB |
Output is correct |
5 |
Correct |
1112 ms |
5428 KB |
Output is correct |
6 |
Correct |
1146 ms |
5428 KB |
Output is correct |
7 |
Correct |
1390 ms |
5428 KB |
Output is correct |
8 |
Correct |
1400 ms |
5428 KB |
Output is correct |
9 |
Correct |
1173 ms |
5548 KB |
Output is correct |
10 |
Correct |
1160 ms |
5548 KB |
Output is correct |
11 |
Correct |
225 ms |
5548 KB |
Output is correct |
12 |
Correct |
1012 ms |
5548 KB |
Output is correct |
13 |
Correct |
1006 ms |
5548 KB |
Output is correct |
14 |
Correct |
1154 ms |
5548 KB |
Output is correct |
15 |
Correct |
1400 ms |
5548 KB |
Output is correct |
16 |
Correct |
1025 ms |
5548 KB |
Output is correct |
17 |
Correct |
1127 ms |
5548 KB |
Output is correct |
18 |
Correct |
1028 ms |
5548 KB |
Output is correct |
19 |
Correct |
1058 ms |
5548 KB |
Output is correct |
20 |
Correct |
1038 ms |
5548 KB |
Output is correct |
21 |
Correct |
1155 ms |
5548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
9 ms |
612 KB |
Output is correct |
3 |
Correct |
11 ms |
688 KB |
Output is correct |
4 |
Correct |
9 ms |
688 KB |
Output is correct |
5 |
Correct |
9 ms |
688 KB |
Output is correct |
6 |
Correct |
11 ms |
688 KB |
Output is correct |
7 |
Correct |
8 ms |
748 KB |
Output is correct |
8 |
Correct |
22 ms |
984 KB |
Output is correct |
9 |
Correct |
20 ms |
984 KB |
Output is correct |
10 |
Correct |
22 ms |
984 KB |
Output is correct |
11 |
Correct |
21 ms |
984 KB |
Output is correct |
12 |
Correct |
21 ms |
984 KB |
Output is correct |
13 |
Correct |
175 ms |
1736 KB |
Output is correct |
14 |
Correct |
150 ms |
1900 KB |
Output is correct |
15 |
Correct |
140 ms |
1900 KB |
Output is correct |
16 |
Correct |
149 ms |
1904 KB |
Output is correct |
17 |
Correct |
140 ms |
1904 KB |
Output is correct |
18 |
Correct |
141 ms |
1904 KB |
Output is correct |
19 |
Correct |
2012 ms |
5428 KB |
Output is correct |
20 |
Correct |
1806 ms |
5428 KB |
Output is correct |
21 |
Correct |
1291 ms |
5428 KB |
Output is correct |
22 |
Correct |
1129 ms |
5428 KB |
Output is correct |
23 |
Correct |
1112 ms |
5428 KB |
Output is correct |
24 |
Correct |
1146 ms |
5428 KB |
Output is correct |
25 |
Correct |
1390 ms |
5428 KB |
Output is correct |
26 |
Correct |
1400 ms |
5428 KB |
Output is correct |
27 |
Correct |
1173 ms |
5548 KB |
Output is correct |
28 |
Correct |
1160 ms |
5548 KB |
Output is correct |
29 |
Correct |
225 ms |
5548 KB |
Output is correct |
30 |
Correct |
1012 ms |
5548 KB |
Output is correct |
31 |
Correct |
1006 ms |
5548 KB |
Output is correct |
32 |
Correct |
1154 ms |
5548 KB |
Output is correct |
33 |
Correct |
1400 ms |
5548 KB |
Output is correct |
34 |
Correct |
1025 ms |
5548 KB |
Output is correct |
35 |
Correct |
1127 ms |
5548 KB |
Output is correct |
36 |
Correct |
1028 ms |
5548 KB |
Output is correct |
37 |
Correct |
1058 ms |
5548 KB |
Output is correct |
38 |
Correct |
1038 ms |
5548 KB |
Output is correct |
39 |
Correct |
1155 ms |
5548 KB |
Output is correct |
40 |
Correct |
2029 ms |
6804 KB |
Output is correct |
41 |
Correct |
848 ms |
6804 KB |
Output is correct |
42 |
Correct |
1183 ms |
6804 KB |
Output is correct |
43 |
Correct |
1041 ms |
6804 KB |
Output is correct |
44 |
Correct |
1060 ms |
6804 KB |
Output is correct |
45 |
Correct |
2265 ms |
13208 KB |
Output is correct |
46 |
Correct |
921 ms |
13208 KB |
Output is correct |
47 |
Correct |
1532 ms |
13324 KB |
Output is correct |
48 |
Correct |
1228 ms |
13324 KB |
Output is correct |
49 |
Correct |
1179 ms |
13324 KB |
Output is correct |