Submission #835984

#TimeUsernameProblemLanguageResultExecution timeMemory
835984HanksburgerLottery (CEOI18_lot)C++17
100 / 100
454 ms12108 KiB
#include <bits/stdc++.h> using namespace std; int a[10005], s[10005], lb[10005], ans[105][10005], res[105][10005]; pair<int, int> k[10005]; int main() { // ios::sync_with_stdio(0); // cin.tie(0); //cout.tie(0); int n, l, q; cin >> n >> l; for (int i=1; i<=n; i++) cin >> a[i]; cin >> q; for (int i=1; i<=q; i++) { cin >> k[i].first; k[i].second=i; } sort(k+1, k+q+1); for (int i=1; i<=q; i++) if (!lb[k[i].first]) lb[k[i].first]=i; lb[l+1]=1e9; for (int i=l; i>=0; i--) if (!lb[i]) lb[i]=lb[i+1]; for (int i=1; i<n-l+1; i++) { for (int j=1; j<=n-l+1-i; j++) s[j]=0; for (int u=1, v=i+1; v<=n; u++, v++) if (a[u]-a[v]) s[max(1, u-l+1)]++, s[min(n-l+2-i, u+1)]--; for (int j=1; j<=n-l+1-i; j++) { s[j]+=s[j-1]; if (lb[s[j]]!=1e9) { ans[lb[s[j]]][j]++; ans[lb[s[j]]][j+i]++; } } } for (int i=1; i<=n-l+1; i++) for (int j=2; j<=q; j++) ans[j][i]+=ans[j-1][i]; for (int i=1; i<=q; i++) for (int j=1; j<=n-l+1; j++) res[k[i].second][j]=ans[lb[k[i].first]][j]; for (int i=1; i<=q; i++) { for (int j=1; j<=n-l+1; j++) cout << res[i][j] << ' '; 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...