Submission #979182

#TimeUsernameProblemLanguageResultExecution timeMemory
979182duckindogLottery (CEOI18_lot)C++17
0 / 100
297 ms1104 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...