제출 #362201

#제출 시각아이디문제언어결과실행 시간메모리
362201sumit_kk10Lottery (CEOI18_lot)C++14
0 / 100
2107 ms8816 KiB
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1e4;
int ans[N][102];
int n, k, q, a[N], dis, ok[N];

void solve() {
    cin >> n >> k;
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    for(int i = 0; i <= n - k; ++i) {
        for (int j = i + 1; j <= n - k; ++j) {
            if (i == j)
                continue;
            int diff = 0;
            for (int e = 0; e < k; ++e)
                if (a[i + e] != a[j + e])
                    ++diff;
            ans[i][ok[i]] = diff;
            ans[j][ok[j]] = diff;
            ok[i]++;
            ok[j]++;
        }
        sort(ans[i], ans[i] + ok[i]);
    }
    cin >> q;
    while(q--){
        cin >> dis;
        for(int i = 0; i <= n - k; ++i){
            int low = 0, high = ok[i] - 1, ok = -1;
            while(low <= high){
                int mid = (low + high) / 2;
                if(ans[i][mid] <= dis){
                    ok = mid;
                    low = mid + 1;
                }
                else
                    high = mid - 1;
            }
            if(ok == -1) cout << "0 ";
            else cout << ok + 1 << " ";
        }
        cout << "\n";
    }
}

int main() {
    fast;
    int t = 1;
    // cin >> t;
    while(t--)
        solve();
    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...