Submission #132842

# Submission time Handle Problem Language Result Execution time Memory
132842 2019-07-19T18:05:22 Z Minnakhmetov Lottery (CEOI18_lot) C++14
0 / 100
3 ms 604 KB
#include<bits/stdc++.h>
using namespace std;

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

const int N = 305;
int a[N], b[N][N], ans[N];

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];
    }

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

                //cout << x << " " << x + j - i << " " << y - j + i << " " << y << "\n";
            }
        }
    }

    for (int i = 1; i < n; i++) {
        for (int j = 1; j < n; j++) {
            b[i][j] += b[i - 1][j - 1];
        }
    }

    int q;
    cin >> q;

    while (q--) {
        int k;
        cin >> k;

        fill(ans, ans + n, 0);

        for (int i = 0; i <= n - l; i++) {
            for (int j = i + 1; j <= n - l; j++) {
                if (b[i][j] <= k) {
                    ans[i]++;
                    ans[j]++;
                }
            }
        }

        for (int i = 0; i < n - l + 1; i++) {
            cout << ans[i] << " ";
        }
        cout << "\n";
    }



    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Runtime error 3 ms 604 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Runtime error 3 ms 604 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Runtime error 3 ms 604 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -