結果

問題 No.2792 Security Cameras on Young Diagram
ユーザー haihamabossuhaihamabossu
提出日時 2024-06-21 22:49:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 910 bytes
コンパイル時間 1,994 ms
コンパイル使用メモリ 204,976 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-24 18:46:03
合計ジャッジ時間 3,157 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
5,248 KB
testcase_01 AC 15 ms
5,248 KB
testcase_02 AC 16 ms
5,376 KB
testcase_03 AC 16 ms
5,376 KB
testcase_04 AC 16 ms
5,376 KB
testcase_05 AC 16 ms
5,376 KB
testcase_06 AC 16 ms
5,376 KB
testcase_07 AC 15 ms
5,376 KB
testcase_08 AC 16 ms
5,376 KB
testcase_09 AC 16 ms
5,376 KB
testcase_10 AC 16 ms
5,376 KB
testcase_11 AC 16 ms
5,376 KB
testcase_12 AC 21 ms
5,376 KB
testcase_13 AC 19 ms
5,376 KB
testcase_14 AC 20 ms
5,376 KB
testcase_15 AC 18 ms
5,376 KB
testcase_16 AC 21 ms
5,376 KB
testcase_17 AC 22 ms
5,376 KB
testcase_18 AC 17 ms
5,376 KB
testcase_19 AC 17 ms
5,376 KB
testcase_20 AC 18 ms
5,376 KB
testcase_21 AC 16 ms
5,376 KB
testcase_22 AC 16 ms
5,376 KB
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using mint = atcoder::modint998244353;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

const int MX = 100'010;
mint fact[MX + 10], finv[MX + 10];

mint c(ll a, ll b) {
  if (a < b || a < 0 || b < 0)
    return 0;
  return fact[a] * finv[a - b] * finv[b];
}

void solve() {
  fact[0] = finv[0] = 1;
  rep(i, MX) {
    fact[i + 1] = fact[i] * (i + 1);
    finv[i + 1] = fact[i + 1].inv();
  }
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  a.push_back(0);
  mint ans = 1;
  rep(i, n + 1) {
    if (i > 0 && a[i - 1] > a[i])
      for (ll j = a[i - 1]; j > a[i]; j--)
        ans += c(j + i - 1, i - 1);
  }
  cout << ans.val() << '\n';
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  int T = 1;
  for (int t = 0; t < T; t++) {
    solve();
  }
  return 0;
}
0