Submission #518775

# Submission time Handle Problem Language Result Execution time Memory
518775 2022-01-24T15:22:47 Z Yazan_Alattar Lottery (CEOI18_lot) C++14
100 / 100
1629 ms 8336 KB
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <utility>
#include <cmath>
#include <numeric>
#include <assert.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 10007;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int n, l, q, a[M], cnt[M][102], Q[M], qry[M], pref[M];

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> l;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    cin >> q;
    for(int i = 1; i <= q; ++i) cin >> qry[i], Q[i] = qry[i];
    sort(Q + 1, Q + q + 1);
    for(int j = 1; j < n; ++j){
        for(int i = 1; i + j <= n; ++i) pref[i] = pref[i - 1] + (a[i] != a[i + j]);
        for(int i = 1; i + j + l - 1 <= n; ++i){
            int dist = pref[i + l - 1] - pref[i - 1];
            ++cnt[i][lower_bound(Q + 1, Q + q + 1, dist) - Q];
            ++cnt[i + j][lower_bound(Q + 1, Q + q + 1, dist) - Q];
        }
    }
    for(int i = 1; i <= n - l + 1; ++i) for(int j = 1; j <= q; ++j) cnt[i][j] += cnt[i][j - 1];
    for(int i = 1; i <= q; ++i){
        for(int j = 1; j <= n - l + 1; ++j) cout << cnt[j][lower_bound(Q + 1, Q + q + 1, qry[i]) - Q] << " ";
        cout << endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 448 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 2 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 448 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 2 ms 460 KB Output is correct
13 Correct 32 ms 1148 KB Output is correct
14 Correct 19 ms 912 KB Output is correct
15 Correct 16 ms 912 KB Output is correct
16 Correct 26 ms 1080 KB Output is correct
17 Correct 25 ms 1020 KB Output is correct
18 Correct 22 ms 1040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 529 ms 4392 KB Output is correct
2 Correct 457 ms 4396 KB Output is correct
3 Correct 444 ms 4404 KB Output is correct
4 Correct 424 ms 4424 KB Output is correct
5 Correct 200 ms 2488 KB Output is correct
6 Correct 430 ms 4216 KB Output is correct
7 Correct 221 ms 2484 KB Output is correct
8 Correct 303 ms 3284 KB Output is correct
9 Correct 449 ms 4352 KB Output is correct
10 Correct 388 ms 4396 KB Output is correct
11 Correct 23 ms 1104 KB Output is correct
12 Correct 237 ms 3232 KB Output is correct
13 Correct 231 ms 2848 KB Output is correct
14 Correct 224 ms 2848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 529 ms 4392 KB Output is correct
2 Correct 457 ms 4396 KB Output is correct
3 Correct 444 ms 4404 KB Output is correct
4 Correct 424 ms 4424 KB Output is correct
5 Correct 200 ms 2488 KB Output is correct
6 Correct 430 ms 4216 KB Output is correct
7 Correct 221 ms 2484 KB Output is correct
8 Correct 303 ms 3284 KB Output is correct
9 Correct 449 ms 4352 KB Output is correct
10 Correct 388 ms 4396 KB Output is correct
11 Correct 23 ms 1104 KB Output is correct
12 Correct 237 ms 3232 KB Output is correct
13 Correct 231 ms 2848 KB Output is correct
14 Correct 224 ms 2848 KB Output is correct
15 Correct 473 ms 4264 KB Output is correct
16 Correct 361 ms 4076 KB Output is correct
17 Correct 464 ms 4476 KB Output is correct
18 Correct 406 ms 4440 KB Output is correct
19 Correct 418 ms 4552 KB Output is correct
20 Correct 401 ms 4444 KB Output is correct
21 Correct 423 ms 4436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 448 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 2 ms 460 KB Output is correct
13 Correct 32 ms 1148 KB Output is correct
14 Correct 19 ms 912 KB Output is correct
15 Correct 16 ms 912 KB Output is correct
16 Correct 26 ms 1080 KB Output is correct
17 Correct 25 ms 1020 KB Output is correct
18 Correct 22 ms 1040 KB Output is correct
19 Correct 529 ms 4392 KB Output is correct
20 Correct 457 ms 4396 KB Output is correct
21 Correct 444 ms 4404 KB Output is correct
22 Correct 424 ms 4424 KB Output is correct
23 Correct 200 ms 2488 KB Output is correct
24 Correct 430 ms 4216 KB Output is correct
25 Correct 221 ms 2484 KB Output is correct
26 Correct 303 ms 3284 KB Output is correct
27 Correct 449 ms 4352 KB Output is correct
28 Correct 388 ms 4396 KB Output is correct
29 Correct 23 ms 1104 KB Output is correct
30 Correct 237 ms 3232 KB Output is correct
31 Correct 231 ms 2848 KB Output is correct
32 Correct 224 ms 2848 KB Output is correct
33 Correct 473 ms 4264 KB Output is correct
34 Correct 361 ms 4076 KB Output is correct
35 Correct 464 ms 4476 KB Output is correct
36 Correct 406 ms 4440 KB Output is correct
37 Correct 418 ms 4552 KB Output is correct
38 Correct 401 ms 4444 KB Output is correct
39 Correct 423 ms 4436 KB Output is correct
40 Correct 1047 ms 5132 KB Output is correct
41 Correct 152 ms 896 KB Output is correct
42 Correct 714 ms 5088 KB Output is correct
43 Correct 641 ms 4636 KB Output is correct
44 Correct 688 ms 4816 KB Output is correct
45 Correct 1629 ms 8200 KB Output is correct
46 Correct 151 ms 1160 KB Output is correct
47 Correct 1124 ms 8336 KB Output is correct
48 Correct 912 ms 6488 KB Output is correct
49 Correct 874 ms 7000 KB Output is correct