結果

問題 No.2158 X日後に全完するhibit君
ユーザー SSRSSSRS
提出日時 2022-12-09 22:17:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,801 bytes
コンパイル時間 1,798 ms
コンパイル使用メモリ 168,180 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 22:24:55
合計ジャッジ時間 2,771 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  cout << fixed << setprecision(10);
  int N, K;
  cin >> N >> K;
  vector<int> P(N), s(N), t(N);
  for (int i = 0; i < N; i++){
    cin >> P[i] >> s[i] >> t[i];
  }
  int ss = 0, st = 0;
  for (int i = 0; i < N; i++){
    ss += s[i];
    st += t[i];
  }
  if (st > 60){
    cout << -1 << endl;
  } else if (ss <= 60){
    cout << 1 << ' ' << 1 << ' ' << 1 << endl;
  } else {
    int mn = K + 2, mx = K + 2;
    for (int i = 0; i < N; i++){
      mx += P[i] - (K + 1);
    }
    vector<int> pr(N + 1);
    pr[0] = 1;
    for (int i = 0; i < N; i++){
      pr[i + 1] = pr[i] * (P[i] + 1);
    }
    vector<double> dp(pr[N], 0);
    for (int i = pr[N] - 1; i >= 0; i--){
      int x = i;
      vector<int> A(N);
      for (int j = 0; j < N; j++){
        A[j] = x % (P[j] + 1);
        x /= P[j] + 1;
      }
      for (int j = 0; j < (1 << N); j++){
        int sum = 0;
        int i2 = 0;
        double p = 1;
        for (int k = 0; k < N; k++){
          if ((j >> k & 1) == 0){
            if (A[k] <= K){
              p = 0;
              break;
            } else {
              sum += t[k];
              i2 += A[k] * pr[k];
              p *= A[k] - K;
              p /= P[k] - K;
            }
          }
          if ((j >> k & 1) == 1){
            if (A[k] == P[k]){
              p = 0;
              break;
            } else {
              sum += s[k];
              i2 += (A[k] + 1) * pr[k];
              p *= P[k] - max(A[k], K);
              p /= P[k] - K;
            }
          }
        }
        if (p != 0){
          if (sum <= 60){
            dp[i] += p;
          } else {
            dp[i] += (dp[i2] + 1) * p;
          }
        }
      }
    }
    cout << mn << ' ' << mx << ' ' << dp[0] << endl;
  }
}
0