답안 #698982

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
698982 2023-02-15T07:06:55 Z dattranxxx Lottery (CEOI18_lot) C++11
35 / 100
335 ms 596 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];
pair<int, int> kq[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].fi;
    kq[i].se = i;
  }
  kq[q + 1] = make_pair(n + 1, q + 1);
  
  sort(kq + 1, kq + q + 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].fi < dif) j++;
    
    ans[kq[j].se][1]++;
    ans[kq[j].se][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].fi < dif) j++;
      while (j - 1 >= 1 && kq[j - 1].fi >= dif) j--;
      ans[kq[j].se][i]++;
      ans[kq[j].se][i + k]++;
    }
  }
  
  for (int i = 1; i <= q; ++i) {
    for (int j = 1; j <= n - l + 1; ++j) {
      ans[i][j] += ans[i - 1][j];
      cout << ans[i][j] << ' ';
    }
    cout << '\n';
  }
  
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 335 ms 448 KB Output is correct
2 Correct 279 ms 468 KB Output is correct
3 Correct 274 ms 468 KB Output is correct
4 Correct 267 ms 532 KB Output is correct
5 Correct 87 ms 468 KB Output is correct
6 Correct 240 ms 588 KB Output is correct
7 Correct 88 ms 480 KB Output is correct
8 Correct 142 ms 480 KB Output is correct
9 Correct 259 ms 520 KB Output is correct
10 Correct 259 ms 520 KB Output is correct
11 Correct 13 ms 368 KB Output is correct
12 Correct 144 ms 480 KB Output is correct
13 Correct 117 ms 480 KB Output is correct
14 Correct 114 ms 472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 335 ms 448 KB Output is correct
2 Correct 279 ms 468 KB Output is correct
3 Correct 274 ms 468 KB Output is correct
4 Correct 267 ms 532 KB Output is correct
5 Correct 87 ms 468 KB Output is correct
6 Correct 240 ms 588 KB Output is correct
7 Correct 88 ms 480 KB Output is correct
8 Correct 142 ms 480 KB Output is correct
9 Correct 259 ms 520 KB Output is correct
10 Correct 259 ms 520 KB Output is correct
11 Correct 13 ms 368 KB Output is correct
12 Correct 144 ms 480 KB Output is correct
13 Correct 117 ms 480 KB Output is correct
14 Correct 114 ms 472 KB Output is correct
15 Correct 262 ms 468 KB Output is correct
16 Correct 229 ms 588 KB Output is correct
17 Correct 275 ms 532 KB Output is correct
18 Correct 266 ms 596 KB Output is correct
19 Correct 269 ms 540 KB Output is correct
20 Correct 272 ms 532 KB Output is correct
21 Correct 270 ms 524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -