Submission #1000587

#TimeUsernameProblemLanguageResultExecution timeMemory
1000587codefoxLottery (CEOI18_lot)C++14
100 / 100
255 ms8680 KiB
#include<bits/stdc++.h> using namespace std; #define pii pair<int, int> int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); int n, l; cin >> n >> l; map<int, int> nn; vector<int> nums(n); vector<vector<int>> ns(n+1); int d=0; for (int i = 0; i < n; i++) { int a; cin >> a; if (nn[a]==0) nn[a] = ++d; nums[i] = nn[a]; ns[nn[a]].push_back(i); } int q; cin >> q; vector<int> qs(q); vector<vector<int>> ans(q, vector<int>(n-l+1, 0)); for (int i = 0; i < q; i++) cin >> qs[i]; vector<int> inter(2*n, 0); int r = 0; for (int i = 0; i <= n-l; i++) { if (i) { for (int ele:ns[nums[i-1]]) { inter[ele-i+1+n]--; } } while (r-i < l) { for (int ele:ns[nums[r]]) { inter[ele-r+n]++; } r++; } vector<int> qqs(n+1, 0); for (int j = n-i; j < n+n-i-l+1; j++) qqs[inter[j]]++; for (int j = n-1; j >=0; j--) qqs[j] += qqs[j+1]; for (int j = 0; j < q; j++) { ans[j][i] = qqs[l-qs[j]]-1; } } for (auto ele:ans) { for (int ele2:ele) cout << ele2 << " "; 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...