Submission #248763

#TimeUsernameProblemLanguageResultExecution timeMemory
248763SortingLottery (CEOI18_lot)C++14
45 / 100
1018 ms65540 KiB
#include <bits/stdc++.h> using namespace std; const int k_N = 1e4 + 3; int n, l; int a[k_N]; short cnt[k_N][k_N]; short prefix[k_N]; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> l; for(int i = 0; i < n; ++i) cin >> a[i]; int q; cin >> q; for(int d = 1; d < n - l + 1; d++){ prefix[0] = (a[0] != a[d]); for(int i = 1; i < n - d; ++i) prefix[i] = (a[i] != a[i + d]) + prefix[i - 1]; for(int i = 0; i < n - l + 1 - d; ++i){ int sum = prefix[i + l - 1]; if(i) sum -= prefix[i - 1]; cnt[i][sum]++; cnt[i + d][sum]++; } } for(int i = 0; i < n; ++i) for(int j = 1; j < n; ++j) cnt[i][j] += cnt[i][j - 1]; for(int i = 0; i < q; ++i){ int k; cin >> k; for(int j = 0; j < n - l + 1; ++j) cout << cnt[j][k] << " "; cout << "\n"; } }
#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...