Submission #979189

# Submission time Handle Problem Language Result Execution time Memory
979189 2024-05-10T11:06:40 Z duckindog Lottery (CEOI18_lot) C++17
100 / 100
818 ms 8672 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 10'000 + 10;
int n, l;
int a[N];
int q;
int Q[N];

int32_t main() { 
  cin.tie(0)->sync_with_stdio(0);

  cin >> n >> l;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  cin >> q;
  for (int i = 1; i <= q; ++i) cin >> Q[i];

  vector<int> rrh(Q + 1, Q + q + 1);
  sort(rrh.begin(), rrh.end());
  rrh.resize(unique(rrh.begin(), rrh.end()) - rrh.begin());

  vector<vector<int>> f(n + 2, vector<int> (rrh.size() + 2));

  for (int i = 2; i <= n - l + 1; ++i) {
    int sum = 0;
    for (int j = 1; j <= l; ++j) sum += a[i + j - 1] != a[j];
    int cnt = 0;
    {
      int it = lower_bound(rrh.begin(), rrh.end(), sum) - rrh.begin() + 1;
      f[i + cnt][it] += 1;
      f[1 + cnt][it] += 1;
    }

    for (int j = l + 1; j <= n; ++j) { 
      if (i + cnt + l > n) break;
      
      sum -= a[i + cnt] != a[1 + cnt];
      cnt += 1;
      sum += a[i + cnt + l - 1] != a[cnt + l];
      
      int it = lower_bound(rrh.begin(), rrh.end(), sum) - rrh.begin() + 1;
      f[i + cnt][it] += 1;
      f[1 + cnt][it] += 1;
    }
  }

  for (int i = 1; i <= n; ++i) { 
    for (int j = 1; j <= rrh.size(); ++j) f[i][j] += f[i][j - 1];
  }

  for (int i = 1; i <= q; ++i) { 
    int it = lower_bound(rrh.begin(), rrh.end(), Q[i]) - rrh.begin() + 1;
    for (int j = 1; j <= n - l + 1; ++j) cout << f[j][it] << " \n"[j == n - l + 1];
  }
}

Compilation message

lot.cpp: In function 'int32_t main()':
lot.cpp:49:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for (int j = 1; j <= rrh.size(); ++j) f[i][j] += f[i][j - 1];
      |                     ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 14 ms 604 KB Output is correct
14 Correct 8 ms 600 KB Output is correct
15 Correct 8 ms 604 KB Output is correct
16 Correct 13 ms 604 KB Output is correct
17 Correct 12 ms 604 KB Output is correct
18 Correct 12 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 285 ms 1108 KB Output is correct
2 Correct 245 ms 1060 KB Output is correct
3 Correct 217 ms 1056 KB Output is correct
4 Correct 213 ms 1160 KB Output is correct
5 Correct 76 ms 1148 KB Output is correct
6 Correct 210 ms 1132 KB Output is correct
7 Correct 68 ms 1144 KB Output is correct
8 Correct 118 ms 1160 KB Output is correct
9 Correct 221 ms 1112 KB Output is correct
10 Correct 241 ms 1116 KB Output is correct
11 Correct 10 ms 652 KB Output is correct
12 Correct 136 ms 1068 KB Output is correct
13 Correct 97 ms 1132 KB Output is correct
14 Correct 93 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 285 ms 1108 KB Output is correct
2 Correct 245 ms 1060 KB Output is correct
3 Correct 217 ms 1056 KB Output is correct
4 Correct 213 ms 1160 KB Output is correct
5 Correct 76 ms 1148 KB Output is correct
6 Correct 210 ms 1132 KB Output is correct
7 Correct 68 ms 1144 KB Output is correct
8 Correct 118 ms 1160 KB Output is correct
9 Correct 221 ms 1112 KB Output is correct
10 Correct 241 ms 1116 KB Output is correct
11 Correct 10 ms 652 KB Output is correct
12 Correct 136 ms 1068 KB Output is correct
13 Correct 97 ms 1132 KB Output is correct
14 Correct 93 ms 1116 KB Output is correct
15 Correct 216 ms 1060 KB Output is correct
16 Correct 196 ms 1144 KB Output is correct
17 Correct 246 ms 1132 KB Output is correct
18 Correct 220 ms 1112 KB Output is correct
19 Correct 234 ms 1132 KB Output is correct
20 Correct 221 ms 1152 KB Output is correct
21 Correct 238 ms 1136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 14 ms 604 KB Output is correct
14 Correct 8 ms 600 KB Output is correct
15 Correct 8 ms 604 KB Output is correct
16 Correct 13 ms 604 KB Output is correct
17 Correct 12 ms 604 KB Output is correct
18 Correct 12 ms 736 KB Output is correct
19 Correct 285 ms 1108 KB Output is correct
20 Correct 245 ms 1060 KB Output is correct
21 Correct 217 ms 1056 KB Output is correct
22 Correct 213 ms 1160 KB Output is correct
23 Correct 76 ms 1148 KB Output is correct
24 Correct 210 ms 1132 KB Output is correct
25 Correct 68 ms 1144 KB Output is correct
26 Correct 118 ms 1160 KB Output is correct
27 Correct 221 ms 1112 KB Output is correct
28 Correct 241 ms 1116 KB Output is correct
29 Correct 10 ms 652 KB Output is correct
30 Correct 136 ms 1068 KB Output is correct
31 Correct 97 ms 1132 KB Output is correct
32 Correct 93 ms 1116 KB Output is correct
33 Correct 216 ms 1060 KB Output is correct
34 Correct 196 ms 1144 KB Output is correct
35 Correct 246 ms 1132 KB Output is correct
36 Correct 220 ms 1112 KB Output is correct
37 Correct 234 ms 1132 KB Output is correct
38 Correct 221 ms 1152 KB Output is correct
39 Correct 238 ms 1136 KB Output is correct
40 Correct 450 ms 2388 KB Output is correct
41 Correct 12 ms 1624 KB Output is correct
42 Correct 366 ms 2456 KB Output is correct
43 Correct 323 ms 2032 KB Output is correct
44 Correct 331 ms 2132 KB Output is correct
45 Correct 818 ms 8672 KB Output is correct
46 Correct 19 ms 5212 KB Output is correct
47 Correct 494 ms 8668 KB Output is correct
48 Correct 468 ms 6484 KB Output is correct
49 Correct 438 ms 6992 KB Output is correct