Submission #822006

#TimeUsernameProblemLanguageResultExecution timeMemory
822006NK_Lottery (CEOI18_lot)C++17
35 / 100
458 ms1024 KiB
// Success consists of going from failure to failure without loss of enthusiasm #include <bits/stdc++.h> using namespace std; #define nl '\n' template<class T> using V = vector<T>; using vi = V<int>; int main() { cin.tie(0)->sync_with_stdio(0); int N, L; cin >> N >> L; vi A(N); for(auto& x : A) cin >> x; int Q; cin >> Q; vi K(Q); for(auto& x : K) cin >> x; vi I(Q); iota(begin(I), end(I), 0); sort(begin(I), end(I), [&](int x, int y) { return K[x] < K[y]; }); sort(begin(K), end(K)); V<vi> ans(N - L + 1, vi(Q)); vi P; for(int d = 1; d <= N; d++) { P = {0}; for(int i = 0; i < N - d; i++) { P.push_back(P.back() + (A[i] != A[i + d])); } auto query = [&](int l, int r) { return P[r + 1] - P[l]; }; for(int i = 0; i < N; i++) { int j = i + d; if (j + L - 1 >= N) continue; int k = query(i, i + L - 1); int ki = lower_bound(begin(K), end(K), k) - begin(K); ++ans[i][ki]; ++ans[i + d][ki]; } } for(int i = 0; i < N - L + 1; i++) { for(int x = 1; x < Q; x++) ans[i][x] += ans[i][x-1]; } // vi ord(Q); for(int i = 0; i < Q; i++) ord[I[i]] = i; // for(auto x : I) cout << x << " "; // cout << nl; // for(auto x : ord) cout << x << " "; // cout << nl; for(auto i : I) { // cout << i << nl; for(int x = 0; x < N - L + 1; x++) cout << ans[x][i] << " "; cout << nl; } 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...