結果

問題 No.1608 Yet Another Ants Problem
ユーザー SSRSSSRS
提出日時 2021-07-16 22:06:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 904 bytes
コンパイル時間 1,581 ms
コンパイル使用メモリ 170,968 KB
実行使用メモリ 73,812 KB
最終ジャッジ日時 2023-09-20 14:09:14
合計ジャッジ時間 9,870 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 519 ms
73,664 KB
testcase_15 AC 527 ms
73,484 KB
testcase_16 AC 529 ms
73,544 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 210 ms
31,876 KB
testcase_22 AC 128 ms
21,776 KB
testcase_23 AC 501 ms
70,756 KB
testcase_24 AC 587 ms
73,760 KB
testcase_25 AC 293 ms
73,464 KB
testcase_26 AC 290 ms
73,504 KB
testcase_27 AC 287 ms
73,588 KB
testcase_28 AC 290 ms
73,600 KB
testcase_29 AC 293 ms
73,596 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
int main(){
  int N, L;
  cin >> N >> L;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<vector<long long>> binom(N + 1, vector<long long>(N + 1, 1));
  for (int i = 2; i <= N; i++){
    for (int j =1; j < i; j++){
      binom[i][j] = (binom[i - 1][j - 1] + binom[i - 1][j]) % MOD;
    }
  }
  for (int i = 0; i < N; i++){
    long long ans = 0;
    for (int j = i; j < N; j++){
      int p = lower_bound(A.begin(), A.end(), L - A[j]) - A.begin();
      if (p == i + 1 && j == i){
        p--;
      }
      if (p <= i){
        ans += binom[j - p][i - p];
      }
    }
    for (int j = 0; j <= i; j++){
      int p = lower_bound(A.begin(), A.end(), L - A[j]) - A.begin();
      if (p > i){
        ans += binom[p - j - 1][i - j];
      }
    }
    ans %= MOD;
    cout << ans << endl;
  }
}
0