結果
問題 | No.155 生放送とBGM |
ユーザー | Medo Nasser |
提出日時 | 2018-07-03 01:55:17 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,470 ms / 6,000 ms |
コード長 | 2,486 bytes |
コンパイル時間 | 2,123 ms |
コンパイル使用メモリ | 75,712 KB |
実行使用メモリ | 81,216 KB |
最終ジャッジ日時 | 2023-09-13 17:11:13 |
合計ジャッジ時間 | 12,491 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,344 ms
80,660 KB |
testcase_01 | AC | 1,304 ms
81,104 KB |
testcase_02 | AC | 1,243 ms
80,752 KB |
testcase_03 | AC | 66 ms
73,732 KB |
testcase_04 | AC | 304 ms
80,692 KB |
testcase_05 | AC | 139 ms
79,564 KB |
testcase_06 | AC | 1,470 ms
80,716 KB |
testcase_07 | AC | 188 ms
80,916 KB |
testcase_08 | AC | 146 ms
79,424 KB |
testcase_09 | AC | 187 ms
80,760 KB |
testcase_10 | AC | 183 ms
80,668 KB |
testcase_11 | AC | 189 ms
80,832 KB |
testcase_12 | AC | 193 ms
80,864 KB |
testcase_13 | AC | 174 ms
81,216 KB |
testcase_14 | AC | 1,105 ms
81,084 KB |
ソースコード
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[]args) throws Throwable { double fac[] = new double[60]; int maxSum = 25500; double dp1[][] = new double[maxSum + 10][60]; double dp2[][] = new double[maxSum + 10][60]; fac[0] = 1; for (int i = 1 ; i < 60 ; ++i) { fac[i] = 1.0*i * fac[i - 1]; } int s[] = new int[60]; Scanner sc = new Scanner(System.in); int n = sc.nextInt(), l = sc.nextInt(); long sum = 0; l*=60; for (int i = 0 ; i < n ; ++i) { String str = sc.next(); StringTokenizer st = new StringTokenizer(str,":"); int x = new Integer(st.nextToken()), y= new Integer(st.nextToken()); s[i]=x*60+y; sum+=s[i]; } if (l >= sum) { System.out.println(n); return; } dp1[0][0] = 1; for (int i = 0 ; i < n ; ++i) { for (int j = i; j >= 0 ; --j) { for (int cur = 0; cur <= maxSum ; ++cur) { dp1[Math.min(maxSum,cur + s[i])][j + 1] += 1.0*dp1[cur][j]; } } } double ways = 0.0; for (int i = 0 ; i < n ; ++i) { for (int j = 0 ; j < n ; ++j) { for (int cur = 0 ; cur < l ;++cur) { dp2[cur][j] = dp1[cur][j]; if (cur - s[i] >= 0 && j >= 1) { dp2[cur][j] -= dp2[cur - s[i]][j - 1]; } if (j < n && cur + s[i] >= l) { ways += 1.0*(j+1)*(((dp2[cur][j] * 1.0*fac[j] * fac[n - j - 1]))); } } } } System.out.printf("%.15f\n",ways/fac[n]); } static class Scanner { StringTokenizer st; BufferedReader br; public Scanner(InputStream s) { br = new BufferedReader(new InputStreamReader(s)); } public Scanner(String s) throws FileNotFoundException { br = new BufferedReader(new FileReader(new File(s))); } public String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public String nextLine() throws IOException { return br.readLine(); } public double nextDouble() throws IOException { return Double.parseDouble(next()); } public boolean ready() throws IOException { return br.ready(); } } }