# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1022504 |
2024-07-13T15:38:46 Z |
vjudge1 |
Lottery (CEOI18_lot) |
C++17 |
|
197 ms |
8344 KB |
// 23 - 12 - 23
#include<bits/stdc++.h>
using namespace std;
#define read() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define day() time_t now = time(0);char* x = ctime(&now);cerr<<"Right Now Is : "<<x<<"\n"
#define ii pair<int,int>
#define X first
#define Y second
const long long MAX = (int)1e4 + 5;
const long long INF = (int)1e9;
const long long MOD = (int)1e9 + 7;
int n,l,q,a[MAX];
int qrx[MAX];
bool idx[MAX];
int nxt[MAX];
int ans[105][MAX];
signed main(){
read();
cin >> n >> l;
for(int i = 1;i <= n;i++)cin >> a[i];
cin >> q;
vector<int> rt;
for(int i = 1;i <= q;i++){
cin >> qrx[i];
idx[qrx[i]] = 1;
rt.push_back(qrx[i]);
}
sort(rt.begin(),rt.end());
rt.erase(unique(rt.begin(),rt.end()),rt.end());
int k = rt.size() + 1;
for(int i = n;i >= 0;i--){
if(idx[i])k--;
nxt[i] = k;
}
vector<int> f(n + 5,0);
for(int len = 1;len <= n;len++){
for(int i = 1;i <= n;i++) f[i] = 0;
for(int i = 1;i + len <= n;i++)
f[i] = f[i - 1] + (a[i] != a[i + len]);
for(int i = 1;i + l - 1 <= n;i++){
if(i + len + l - 1 > n)break;
int cost = nxt[f[i + l - 1] - f[i - 1]];
ans[cost][i]++;
ans[cost][i + len]++;
}
}
for(int i = 1;i <= (int)rt.size();i++){
for(int j = 1;j <= n;j++){
ans[i][j] += ans[i - 1][j];
}
}
for(int i = 1;i <= q;i++){
int x = lower_bound(rt.begin(),rt.end(),qrx[i]) - rt.begin() + 1;
for(int j = 1;j <= n - l + 1;j++)cout << ans[x][j] << " \n"[j == n - l + 1];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
6 ms |
604 KB |
Output is correct |
14 |
Correct |
5 ms |
604 KB |
Output is correct |
15 |
Correct |
5 ms |
600 KB |
Output is correct |
16 |
Correct |
7 ms |
856 KB |
Output is correct |
17 |
Correct |
6 ms |
600 KB |
Output is correct |
18 |
Correct |
6 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
133 ms |
604 KB |
Output is correct |
2 |
Correct |
128 ms |
604 KB |
Output is correct |
3 |
Correct |
130 ms |
532 KB |
Output is correct |
4 |
Correct |
124 ms |
744 KB |
Output is correct |
5 |
Correct |
68 ms |
696 KB |
Output is correct |
6 |
Correct |
117 ms |
604 KB |
Output is correct |
7 |
Correct |
62 ms |
600 KB |
Output is correct |
8 |
Correct |
83 ms |
692 KB |
Output is correct |
9 |
Correct |
123 ms |
760 KB |
Output is correct |
10 |
Correct |
126 ms |
600 KB |
Output is correct |
11 |
Correct |
8 ms |
348 KB |
Output is correct |
12 |
Correct |
76 ms |
700 KB |
Output is correct |
13 |
Correct |
77 ms |
696 KB |
Output is correct |
14 |
Correct |
71 ms |
696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
133 ms |
604 KB |
Output is correct |
2 |
Correct |
128 ms |
604 KB |
Output is correct |
3 |
Correct |
130 ms |
532 KB |
Output is correct |
4 |
Correct |
124 ms |
744 KB |
Output is correct |
5 |
Correct |
68 ms |
696 KB |
Output is correct |
6 |
Correct |
117 ms |
604 KB |
Output is correct |
7 |
Correct |
62 ms |
600 KB |
Output is correct |
8 |
Correct |
83 ms |
692 KB |
Output is correct |
9 |
Correct |
123 ms |
760 KB |
Output is correct |
10 |
Correct |
126 ms |
600 KB |
Output is correct |
11 |
Correct |
8 ms |
348 KB |
Output is correct |
12 |
Correct |
76 ms |
700 KB |
Output is correct |
13 |
Correct |
77 ms |
696 KB |
Output is correct |
14 |
Correct |
71 ms |
696 KB |
Output is correct |
15 |
Correct |
128 ms |
668 KB |
Output is correct |
16 |
Correct |
112 ms |
740 KB |
Output is correct |
17 |
Correct |
130 ms |
748 KB |
Output is correct |
18 |
Correct |
127 ms |
600 KB |
Output is correct |
19 |
Correct |
129 ms |
1000 KB |
Output is correct |
20 |
Correct |
128 ms |
600 KB |
Output is correct |
21 |
Correct |
127 ms |
752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
6 ms |
604 KB |
Output is correct |
14 |
Correct |
5 ms |
604 KB |
Output is correct |
15 |
Correct |
5 ms |
600 KB |
Output is correct |
16 |
Correct |
7 ms |
856 KB |
Output is correct |
17 |
Correct |
6 ms |
600 KB |
Output is correct |
18 |
Correct |
6 ms |
604 KB |
Output is correct |
19 |
Correct |
133 ms |
604 KB |
Output is correct |
20 |
Correct |
128 ms |
604 KB |
Output is correct |
21 |
Correct |
130 ms |
532 KB |
Output is correct |
22 |
Correct |
124 ms |
744 KB |
Output is correct |
23 |
Correct |
68 ms |
696 KB |
Output is correct |
24 |
Correct |
117 ms |
604 KB |
Output is correct |
25 |
Correct |
62 ms |
600 KB |
Output is correct |
26 |
Correct |
83 ms |
692 KB |
Output is correct |
27 |
Correct |
123 ms |
760 KB |
Output is correct |
28 |
Correct |
126 ms |
600 KB |
Output is correct |
29 |
Correct |
8 ms |
348 KB |
Output is correct |
30 |
Correct |
76 ms |
700 KB |
Output is correct |
31 |
Correct |
77 ms |
696 KB |
Output is correct |
32 |
Correct |
71 ms |
696 KB |
Output is correct |
33 |
Correct |
128 ms |
668 KB |
Output is correct |
34 |
Correct |
112 ms |
740 KB |
Output is correct |
35 |
Correct |
130 ms |
748 KB |
Output is correct |
36 |
Correct |
127 ms |
600 KB |
Output is correct |
37 |
Correct |
129 ms |
1000 KB |
Output is correct |
38 |
Correct |
128 ms |
600 KB |
Output is correct |
39 |
Correct |
127 ms |
752 KB |
Output is correct |
40 |
Correct |
138 ms |
1972 KB |
Output is correct |
41 |
Correct |
47 ms |
1472 KB |
Output is correct |
42 |
Correct |
140 ms |
2028 KB |
Output is correct |
43 |
Correct |
130 ms |
1816 KB |
Output is correct |
44 |
Correct |
150 ms |
1916 KB |
Output is correct |
45 |
Correct |
197 ms |
8344 KB |
Output is correct |
46 |
Correct |
46 ms |
4692 KB |
Output is correct |
47 |
Correct |
185 ms |
8340 KB |
Output is correct |
48 |
Correct |
165 ms |
6228 KB |
Output is correct |
49 |
Correct |
161 ms |
6736 KB |
Output is correct |