답안 #132855

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
132855 2019-07-19T18:39:15 Z Minnakhmetov Lottery (CEOI18_lot) C++14
100 / 100
995 ms 8568 KB
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 10005, Q = 105;
int a[N], b[N], ct[N], ans[N][Q], w[Q], col[N];
vector<int> vs;

signed main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, l;
    cin >> n >> l;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int q;
    cin >> q;

    for (int i = 0; i < q; i++) {
        cin >> w[i];
        vs.push_back(w[i]);
    }

    vs.push_back(-1);

    sort(all(vs));
    vs.erase(unique(all(vs)), vs.end());



    fill(col, col + N, -1);

    for (int i = vs.size() - 1; i > 0; i--) {
        for (int j = vs[i - 1] + 1; j <= vs[i]; j++) {
            col[j] = i;
        }
    }


    for (int i = 1; i <= n - l; i++) {
        fill(b, b + n, 0);
        for (int j = 0; j < n - i; j++) {
            if (a[j] != a[j + i]) {
                int x = min(j, l - 1);
                b[j - x]++;
                b[j + 1]--;
            }
        }
        for (int j = 1; j <= n - l - i; j++) {
            b[j] += b[j - 1];
        }
        for (int j = 0; j <= n - l - i; j++) {
            if (col[b[j]] != -1) {
                ans[j][col[b[j]]]++;
                ans[j + i][col[b[j]]]++;
            }
        }
    }

    for (int i = 1; i < vs.size(); i++) {
        for (int j = 0; j <= n - l; j++) {
            ans[j][i] += ans[j][i - 1];
        }
    }

    for (int i = 0; i < q; i++) {
        int k = lower_bound(all(vs), w[i]) - vs.begin();
        for (int j = 0; j <= n - l; j++) {
            cout << ans[j][k] << " ";
        }
        cout << "\n";
    }


    return 0;
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:70:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 1; i < vs.size(); i++) {
                     ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 508 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 508 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 31 ms 1272 KB Output is correct
14 Correct 18 ms 1016 KB Output is correct
15 Correct 13 ms 1016 KB Output is correct
16 Correct 18 ms 1272 KB Output is correct
17 Correct 17 ms 1160 KB Output is correct
18 Correct 17 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 686 ms 4728 KB Output is correct
2 Correct 592 ms 4628 KB Output is correct
3 Correct 420 ms 4632 KB Output is correct
4 Correct 335 ms 4600 KB Output is correct
5 Correct 156 ms 2652 KB Output is correct
6 Correct 315 ms 4344 KB Output is correct
7 Correct 181 ms 2680 KB Output is correct
8 Correct 315 ms 3576 KB Output is correct
9 Correct 338 ms 4600 KB Output is correct
10 Correct 347 ms 4728 KB Output is correct
11 Correct 23 ms 1272 KB Output is correct
12 Correct 215 ms 3404 KB Output is correct
13 Correct 196 ms 3036 KB Output is correct
14 Correct 193 ms 3032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 686 ms 4728 KB Output is correct
2 Correct 592 ms 4628 KB Output is correct
3 Correct 420 ms 4632 KB Output is correct
4 Correct 335 ms 4600 KB Output is correct
5 Correct 156 ms 2652 KB Output is correct
6 Correct 315 ms 4344 KB Output is correct
7 Correct 181 ms 2680 KB Output is correct
8 Correct 315 ms 3576 KB Output is correct
9 Correct 338 ms 4600 KB Output is correct
10 Correct 347 ms 4728 KB Output is correct
11 Correct 23 ms 1272 KB Output is correct
12 Correct 215 ms 3404 KB Output is correct
13 Correct 196 ms 3036 KB Output is correct
14 Correct 193 ms 3032 KB Output is correct
15 Correct 565 ms 4504 KB Output is correct
16 Correct 306 ms 4344 KB Output is correct
17 Correct 363 ms 4728 KB Output is correct
18 Correct 337 ms 4728 KB Output is correct
19 Correct 336 ms 4744 KB Output is correct
20 Correct 336 ms 4728 KB Output is correct
21 Correct 338 ms 4600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 508 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 31 ms 1272 KB Output is correct
14 Correct 18 ms 1016 KB Output is correct
15 Correct 13 ms 1016 KB Output is correct
16 Correct 18 ms 1272 KB Output is correct
17 Correct 17 ms 1160 KB Output is correct
18 Correct 17 ms 1144 KB Output is correct
19 Correct 686 ms 4728 KB Output is correct
20 Correct 592 ms 4628 KB Output is correct
21 Correct 420 ms 4632 KB Output is correct
22 Correct 335 ms 4600 KB Output is correct
23 Correct 156 ms 2652 KB Output is correct
24 Correct 315 ms 4344 KB Output is correct
25 Correct 181 ms 2680 KB Output is correct
26 Correct 315 ms 3576 KB Output is correct
27 Correct 338 ms 4600 KB Output is correct
28 Correct 347 ms 4728 KB Output is correct
29 Correct 23 ms 1272 KB Output is correct
30 Correct 215 ms 3404 KB Output is correct
31 Correct 196 ms 3036 KB Output is correct
32 Correct 193 ms 3032 KB Output is correct
33 Correct 565 ms 4504 KB Output is correct
34 Correct 306 ms 4344 KB Output is correct
35 Correct 363 ms 4728 KB Output is correct
36 Correct 337 ms 4728 KB Output is correct
37 Correct 336 ms 4744 KB Output is correct
38 Correct 336 ms 4728 KB Output is correct
39 Correct 338 ms 4600 KB Output is correct
40 Correct 919 ms 5368 KB Output is correct
41 Correct 35 ms 1016 KB Output is correct
42 Correct 401 ms 5468 KB Output is correct
43 Correct 340 ms 4984 KB Output is correct
44 Correct 342 ms 5144 KB Output is correct
45 Correct 995 ms 8440 KB Output is correct
46 Correct 42 ms 1272 KB Output is correct
47 Correct 754 ms 8568 KB Output is correct
48 Correct 429 ms 6648 KB Output is correct
49 Correct 427 ms 7288 KB Output is correct