# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
979182 |
2024-05-10T10:51:35 Z |
duckindog |
Lottery (CEOI18_lot) |
C++17 |
|
297 ms |
1104 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 10'000 + 10;
int n, l;
int a[N];
int q;
int Q[N];
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> l;
for (int i = 1; i <= n; ++i) cin >> a[i];
cin >> q;
for (int i = 1; i <= q; ++i) cin >> Q[i];
vector<int> rrh(Q + 1, Q + q + 1);
sort(rrh.begin(), rrh.end());
rrh.resize(unique(rrh.begin(), rrh.end()) - rrh.begin());
vector<vector<int>> f(n + 2, vector<int> (rrh.size() + 2));
for (int i = 2; i <= n - l + 1; ++i) {
int sum = 0;
for (int j = 1; j <= l; ++j) sum += a[i + j - 1] != a[j];
int cnt = 0;
{
int it = upper_bound(rrh.begin(), rrh.end(), sum) - rrh.begin();
f[i + cnt][it] += 1;
f[1 + cnt][it] += 1;
cerr << 1 + cnt << " " << i + cnt << " " << sum << "\n";
}
for (int j = l + 1; j <= n; ++j) {
if (i + cnt + l > n) break;
sum -= a[i + cnt] != a[1 + cnt];
cnt += 1;
sum += a[i + cnt + l - 1] != a[cnt + l];
int it = upper_bound(rrh.begin(), rrh.end(), sum) - rrh.begin();
f[i + cnt][it] += 1;
f[1 + cnt][it] += 1;
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= rrh.size(); ++j) f[i][j] += f[i][j - 1];
}
for (int i = 1; i <= q; ++i) {
int it = lower_bound(rrh.begin(), rrh.end(), Q[i]) - rrh.begin() + 1;
for (int j = 1; j <= n - l + 1; ++j) cout << f[j][it] << " \n"[j == n - l + 1];
}
}
Compilation message
lot.cpp: In function 'int32_t main()':
lot.cpp:51:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
51 | for (int j = 1; j <= rrh.size(); ++j) f[i][j] += f[i][j - 1];
| ~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
297 ms |
1104 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
297 ms |
1104 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |