제출 #261159

#제출 시각아이디문제언어결과실행 시간메모리
261159sjimedLottery (CEOI18_lot)C++14
0 / 100
559 ms536 KiB
#include<bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(false);cin.tie(NULL) #define fi first #define se second #define all(v) (v).begin(),(v).end() #define pb push_back #define eb emplace_back #define em emplace #define pre(a) cout<<fixed; cout.precision(a) #define mp make_pair typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll INF = 1e18; const int inf = 1e9; int n, l, q; int a[10010]; int k[111]; int g[10010]; int ans[10010][111]; int main() { fast; 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]; g[k[i]+1] = 1; } for(int i=1; i<=n; i++) { g[i] += g[i-1]; } for(int i=1; i+l<=n; i++) { int cnt = 0; for(int j=1; j<=l; j++) { if(a[j] != a[j+i]) cnt++; } for(int j=1; j+i <= n-l+1; j++) { ans[g[cnt]][j]++; ans[g[cnt]][j+i]++; if(a[j+i] != a[j]) cnt--; if(a[j+l+i] != a[j+l]) cnt++; } } for(int i=1; i<=q; i++) { for(int j=1; j<=n-l+1; j++) { ans[i][j] += ans[i-1][j]; } } for(int i=1; i<=q; i++) { for(int j=1; j<=n-l+1; j++) { cout << ans[g[k[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...