結果

問題 No.398 ハーフパイプ(2)
ユーザー kk
提出日時 2021-04-05 23:38:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 817 bytes
コンパイル時間 2,332 ms
コンパイル使用メモリ 201,260 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 11:31:37
合計ジャッジ時間 4,904 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
4,376 KB
testcase_01 AC 127 ms
4,376 KB
testcase_02 AC 78 ms
4,376 KB
testcase_03 AC 79 ms
4,380 KB
testcase_04 AC 79 ms
4,376 KB
testcase_05 AC 109 ms
4,380 KB
testcase_06 AC 47 ms
4,380 KB
testcase_07 AC 61 ms
4,376 KB
testcase_08 AC 126 ms
4,380 KB
testcase_09 AC 104 ms
4,380 KB
testcase_10 AC 106 ms
4,380 KB
testcase_11 AC 110 ms
4,380 KB
testcase_12 AC 96 ms
4,380 KB
testcase_13 AC 97 ms
4,380 KB
testcase_14 AC 94 ms
4,376 KB
testcase_15 AC 116 ms
4,376 KB
testcase_16 AC 96 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

long long calc(int l, int r, int sum) {
  if (l > r) return 0;
  vector<long long> dp(sum + 1);
  dp[0] = 1;
  vector<long long> dpsum(sum + 2, 1);
  dpsum[0] = 0;
  
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j <= sum; j++)
      dp[j] = dpsum[max(0, j-l+1)] - dpsum[max(0, j-r)];
    for (int j = 0; j <= sum; j++)
      dpsum[j+1] = dpsum[j] + dp[j];
  }
  return dp[sum];
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  double x;
  cin >> x;

  int score = x * 4;

  long long ret = 0;
  for (int l = 0; l <= 100; l++) {
    for (int r = l; r <= 100; r++) {
      int sum = score + l + r;
      ret += calc(l, r, sum) - calc(l+1, r, sum)
        - calc(l, r-1, sum) + calc(l+1, r-1, sum);
    }
  }
  cout << ret << endl;
  
  return 0;
}
0