# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1091883 |
2024-09-22T13:04:52 Z |
gyg |
Lottery (CEOI18_lot) |
C++17 |
|
3000 ms |
668 KB |
#pragma GCC optimize("Ofast", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
#define arr array
#define vct vector
const int MX_N = 1e4 + 5, MX_Q = 1e2 + 5;
int n, l;
arr<int, MX_N> vl;
int q;
arr<int, MX_Q> qry;
arr<arr<int, MX_N>, 2> sm;
vct<int> sms;
arr<arr<int, MX_N>, MX_Q> ans;
void cmp() {
for (int i = n; i >= 1; i--) {
int prt = i % 2, opp_prt = (i + 1) % 2;
for (int j = 1; j <= n; j++) sm[prt][j] = (vl[i] == vl[j]) + sm[opp_prt][j + 1];
sms.clear();
for (int j = 1; j <= n - l + 1; j++)
if (j != i) sms.push_back(sm[prt][j]);
sort(sms.begin(), sms.end());
for (int j = 1; j <= q; j++)
ans[j][i] = sms.size() - (lower_bound(sms.begin(), sms.end(), l - qry[j]) - sms.begin());
for (int j = 1; j <= n; j++) {
int nw_i = i + l - 1, nw_j = j + l - 1;
if (max(nw_i, nw_j) > n) continue;
sm[prt][j] -= (vl[nw_i] == vl[nw_j]);
}
}
}
signed main() {
// freopen("lttry.in", "r", stdin);
cin >> n >> l;
for (int i = 1; i <= n; i++) cin >> vl[i];
cin >> q;
for (int i = 1; i <= q; i++) cin >> qry[i];
cmp();
for (int i = 1; i <= q; i++) {
for (int j = 1; j <= n - l + 1; j++) cout << ans[i][j] << " ";
cout << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
3 ms |
600 KB |
Output is correct |
12 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
3 ms |
600 KB |
Output is correct |
12 |
Correct |
3 ms |
344 KB |
Output is correct |
13 |
Correct |
128 ms |
520 KB |
Output is correct |
14 |
Correct |
73 ms |
652 KB |
Output is correct |
15 |
Correct |
73 ms |
592 KB |
Output is correct |
16 |
Correct |
104 ms |
600 KB |
Output is correct |
17 |
Correct |
91 ms |
600 KB |
Output is correct |
18 |
Correct |
92 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3043 ms |
668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3043 ms |
668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
3 ms |
600 KB |
Output is correct |
12 |
Correct |
3 ms |
344 KB |
Output is correct |
13 |
Correct |
128 ms |
520 KB |
Output is correct |
14 |
Correct |
73 ms |
652 KB |
Output is correct |
15 |
Correct |
73 ms |
592 KB |
Output is correct |
16 |
Correct |
104 ms |
600 KB |
Output is correct |
17 |
Correct |
91 ms |
600 KB |
Output is correct |
18 |
Correct |
92 ms |
604 KB |
Output is correct |
19 |
Execution timed out |
3043 ms |
668 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |