結果

問題 No.1608 Yet Another Ants Problem
ユーザー SSRSSSRS
提出日時 2021-07-16 22:08:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 599 ms / 2,000 ms
コード長 954 bytes
コンパイル時間 1,755 ms
コンパイル使用メモリ 172,608 KB
実行使用メモリ 73,724 KB
最終ジャッジ日時 2023-09-20 14:12:33
合計ジャッジ時間 10,225 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 527 ms
73,544 KB
testcase_15 AC 533 ms
73,516 KB
testcase_16 AC 531 ms
73,412 KB
testcase_17 AC 529 ms
73,408 KB
testcase_18 AC 532 ms
73,500 KB
testcase_19 AC 37 ms
8,916 KB
testcase_20 AC 218 ms
33,124 KB
testcase_21 AC 206 ms
32,012 KB
testcase_22 AC 130 ms
21,736 KB
testcase_23 AC 502 ms
70,620 KB
testcase_24 AC 599 ms
73,512 KB
testcase_25 AC 289 ms
73,688 KB
testcase_26 AC 288 ms
73,408 KB
testcase_27 AC 292 ms
73,656 KB
testcase_28 AC 289 ms
73,468 KB
testcase_29 AC 288 ms
73,724 KB
testcase_30 AC 247 ms
73,540 KB
testcase_31 AC 249 ms
73,596 KB
testcase_32 AC 247 ms
73,460 KB
testcase_33 AC 249 ms
73,548 KB
testcase_34 AC 250 ms
73,544 KB
権限があれば一括ダウンロードができます

ソースコード

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 && j == i){
        p++;
      }
      if (p > i){
        ans += binom[p - j - 1][i - j];
      }
    }
    ans %= MOD;
    cout << ans << endl;
  }
}
0