Submission #754281

#TimeUsernameProblemLanguageResultExecution timeMemory
754281MetalPowerLottery (CEOI18_lot)C++14
35 / 100
619 ms4556 KiB
#include <bits/stdc++.h> using namespace std; const int MX = 1e4 + 10; int N, L, Q, arr[MX], que[MX], pref[MX], ans[MX][105]; vector<int> sq; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> L; for(int i = 0; i < N; i++) cin >> arr[i]; cin >> Q; for(int i = 0; i < Q; i++){ cin >> que[i]; sq.push_back(que[i]); } sort(sq.begin(), sq.end()); sq.push_back(L); pref[0] = 0; for(int df = 1; df < N - L + 1; df++){ for(int i = 0; i < N - df; i++){ if(arr[i] != arr[i + df]) pref[i] = (i == 0 ? 1 : pref[i - 1] + 1); else pref[i] = (i == 0 ? 0 : pref[i - 1]); } for(int i = 0; i < N - L + 1 - df; i++){ int curr = pref[i + L - 1] - (i == 0 ? 0 : pref[i - 1]); int id = lower_bound(sq.begin(), sq.end(), curr) - sq.begin(); ans[i][id]++; ans[i + df][id]++; } } int sz = sq.size(); for(int i = 0; i < N - L + 1; i++){ for(int j = 1; j < sz; j++) ans[i][j] += ans[i][j - 1]; } for(int i = 0; i < Q; i++){ int id = lower_bound(sq.begin(), sq.end(), que[i]) - sq.begin(); for(int k = 0; k < N - L + 1; k++) cout << ans[k][i] << " "; cout << '\n'; } }

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:44:7: warning: unused variable 'id' [-Wunused-variable]
   44 |   int id = lower_bound(sq.begin(), sq.end(), que[i]) - sq.begin();
      |       ^~
#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...