제출 #483357

#제출 시각아이디문제언어결과실행 시간메모리
483357BERNARB01Lottery (CEOI18_lot)C++17
35 / 100
221 ms392 KiB
#include <bits/stdc++.h> using namespace std; const int N = 10004; int n, l, a[N], q, v[102][N]; pair<int, int> k[102]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> l; for (int i = 0; i < n; i++) { cin >> a[i]; } cin >> q; for (int i = 0; i < q; i++) { cin >> k[i].first; k[i].second = i; } sort(k, k + q); for (int i = 1; i + l <= n; i++) { int c = 0; for (int j = 0; j < l - 1; j++) { c += (a[j] != a[j + i]); } for (int s = 0, ss = i; ss + l <= n; s++, ss++) { c += (a[s + l - 1] != a[ss + l - 1]); if (k[q - 1].first >= c) { int lb = -1, r = q - 1; while (r - lb > 1) { int mid = (lb + r) >> 1; if (k[mid].first >= c) { r = mid; } else { lb = mid; } } v[k[r].second][s] += 1; v[k[r].second][ss] += 1; } c -= (a[s] != a[ss]); } } for (int j = 0; j < q; j++) { for (int i = 0; i + l <= n; i++) { if (j > 0) { v[j][i] += v[j - 1][i]; } if (i > 0) { cout << " "; } cout << v[j][i]; } cout << '\n'; } return 0; }
#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...