結果

問題 No.2158 X日後に全完するhibit君
ユーザー 👑 chro_96chro_96
提出日時 2022-12-09 23:50:24
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,787 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 33,152 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-22 23:20:25
合計ジャッジ時間 1,119 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int main () {
  int n = 0;
  int k = 0;
  int p[6] = {};
  int s[6] = {};
  int t[6] = {};
  
  int res = 0;
  
  double ans = 0.0;
  int sum_s = 0;
  int sum_t = 0;
  
  double prob[22][5000] = {};
  
  int min = 22;
  int max = 0;
  
  res = scanf("%d", &n);
  res = scanf("%d", &k);
  for (int i = 0; i < n; i++) {
    res = scanf("%d", p+i);
    res = scanf("%d", s+i);
    res = scanf("%d", t+i);
    sum_s += s[i];
    sum_t += t[i];
  }
  
  if (sum_s <= 60) {
    printf("1 1 1\n");
    return 0;
  }
  
  if (sum_t > 60) {
    printf("-1\n");
    return 0;
  }
  
  prob[k+1][0] = 1.0;
  
  for (int i = k+1; i < 21; i++) {
    for (int j = 0; j < (1<<(2*n)); j++) {
      if (prob[i][j] > 0.0) {
        int num[6] = {};
        for (int l = 0; l < n; l++) {
          num[l] = (j>>(l*2))%4+1;
        }
        for (int l = 0; l < (1<<n); l++) {
          int sum_st = 0;
          int mul = 1;
          int div = 1;
          double tmp_prob = prob[i][j];
          int nxt = 0;
          for (int q = 0; q < n; q++) {
            if ((l&(1<<q)) > 0) {
              sum_st += t[q];
              mul *= num[q];
              nxt += ((num[q]-1)<<(2*q));
            } else {
              sum_st += s[q];
              mul *= p[q]-k-num[q];
              nxt += ((num[q])<<(2*q));
            }
            div *= p[q]-k;
          }
          tmp_prob *= ((double)mul)/((double)div);
          if (sum_st > 60) {
            prob[i+1][nxt] += tmp_prob;
          } else {
            ans += tmp_prob*((double)(i+1));
            if (min > i+1) {
              min = i+1;
            }
            if (max < i+1) {
              max = i+1;
            }
          }
        }
      }
    }
  }
  
  printf("%d %d %.16lf\n", min, max, ans);
  return 0;
}
0