Submission #698983

# Submission time Handle Problem Language Result Execution time Memory
698983 2023-02-15T07:12:53 Z dattranxxx Lottery (CEOI18_lot) C++11
100 / 100
512 ms 8240 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 1e4 + 5;
int a[N];
int n, l, q;

int ans[105][N];
int kq[105];
int queries[105];

#define fi first
#define se second

int main() {
  cin.tie(0)->sync_with_stdio(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 >> kq[i];
    queries[i] = kq[i];
  }
  
  sort(kq + 1, kq + q + 1);
  int m = unique(kq + 1, kq + q + 1) - kq - 1;
  kq[m + 1] = n + 1;
  
  for (int k = 1; l + k <= n; ++k) {
    
    int dif = 0;
    for (int i = 1; i <= l; ++i) {
      dif += a[i] != a[i + k];
    }
    
    int j = 1;
    while (kq[j] < dif) j++;
    
    ans[j][1]++;
    ans[j][1 + k]++;
    
    
    for (int i = 2; i + k + l - 1 <= n; ++i) {
      dif -= a[i - 1] != a[i + k - 1];
      dif += a[i + l - 1] != a[i + k + l - 1];
      while (kq[j] < dif) j++;
      while (j - 1 >= 1 && kq[j - 1] >= dif) j--;
      ans[j][i]++;
      ans[j][i + k]++;
    }
  }
  
  for (int i = 1; i <= m; ++i) {
    for (int j = 1; j <= n - l + 1; ++j) {
      ans[i][j] += ans[i - 1][j];
    }
  }
  
  for (int i = 1; i <= q; ++i) {
    int id = lower_bound(kq + 1, kq + m + 1, queries[i]) - kq;
    for (int j = 1; j <= n - l + 1; ++j) {
      cout << ans[id][j] << ' ';
    }
    cout << '\n';
  }
  
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 10 ms 448 KB Output is correct
14 Correct 6 ms 596 KB Output is correct
15 Correct 5 ms 468 KB Output is correct
16 Correct 8 ms 596 KB Output is correct
17 Correct 7 ms 596 KB Output is correct
18 Correct 7 ms 580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 221 ms 424 KB Output is correct
2 Correct 147 ms 424 KB Output is correct
3 Correct 136 ms 432 KB Output is correct
4 Correct 138 ms 424 KB Output is correct
5 Correct 63 ms 388 KB Output is correct
6 Correct 126 ms 408 KB Output is correct
7 Correct 50 ms 372 KB Output is correct
8 Correct 77 ms 380 KB Output is correct
9 Correct 129 ms 428 KB Output is correct
10 Correct 138 ms 432 KB Output is correct
11 Correct 7 ms 340 KB Output is correct
12 Correct 76 ms 384 KB Output is correct
13 Correct 65 ms 368 KB Output is correct
14 Correct 67 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 221 ms 424 KB Output is correct
2 Correct 147 ms 424 KB Output is correct
3 Correct 136 ms 432 KB Output is correct
4 Correct 138 ms 424 KB Output is correct
5 Correct 63 ms 388 KB Output is correct
6 Correct 126 ms 408 KB Output is correct
7 Correct 50 ms 372 KB Output is correct
8 Correct 77 ms 380 KB Output is correct
9 Correct 129 ms 428 KB Output is correct
10 Correct 138 ms 432 KB Output is correct
11 Correct 7 ms 340 KB Output is correct
12 Correct 76 ms 384 KB Output is correct
13 Correct 65 ms 368 KB Output is correct
14 Correct 67 ms 384 KB Output is correct
15 Correct 146 ms 428 KB Output is correct
16 Correct 121 ms 424 KB Output is correct
17 Correct 146 ms 444 KB Output is correct
18 Correct 148 ms 428 KB Output is correct
19 Correct 140 ms 436 KB Output is correct
20 Correct 136 ms 428 KB Output is correct
21 Correct 135 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 10 ms 448 KB Output is correct
14 Correct 6 ms 596 KB Output is correct
15 Correct 5 ms 468 KB Output is correct
16 Correct 8 ms 596 KB Output is correct
17 Correct 7 ms 596 KB Output is correct
18 Correct 7 ms 580 KB Output is correct
19 Correct 221 ms 424 KB Output is correct
20 Correct 147 ms 424 KB Output is correct
21 Correct 136 ms 432 KB Output is correct
22 Correct 138 ms 424 KB Output is correct
23 Correct 63 ms 388 KB Output is correct
24 Correct 126 ms 408 KB Output is correct
25 Correct 50 ms 372 KB Output is correct
26 Correct 77 ms 380 KB Output is correct
27 Correct 129 ms 428 KB Output is correct
28 Correct 138 ms 432 KB Output is correct
29 Correct 7 ms 340 KB Output is correct
30 Correct 76 ms 384 KB Output is correct
31 Correct 65 ms 368 KB Output is correct
32 Correct 67 ms 384 KB Output is correct
33 Correct 146 ms 428 KB Output is correct
34 Correct 121 ms 424 KB Output is correct
35 Correct 146 ms 444 KB Output is correct
36 Correct 148 ms 428 KB Output is correct
37 Correct 140 ms 436 KB Output is correct
38 Correct 136 ms 428 KB Output is correct
39 Correct 135 ms 460 KB Output is correct
40 Correct 238 ms 1876 KB Output is correct
41 Correct 11 ms 596 KB Output is correct
42 Correct 157 ms 2104 KB Output is correct
43 Correct 148 ms 1696 KB Output is correct
44 Correct 141 ms 1696 KB Output is correct
45 Correct 512 ms 8064 KB Output is correct
46 Correct 16 ms 1488 KB Output is correct
47 Correct 210 ms 8240 KB Output is correct
48 Correct 201 ms 6084 KB Output is correct
49 Correct 192 ms 6604 KB Output is correct