結果

問題 No.472 平均順位
ユーザー tentententen
提出日時 2023-06-14 08:47:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,444 ms / 2,000 ms
コード長 2,231 bytes
コンパイル時間 2,603 ms
コンパイル使用メモリ 91,528 KB
実行使用メモリ 56,060 KB
最終ジャッジ日時 2023-09-04 23:22:02
合計ジャッジ時間 13,839 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,432 KB
testcase_01 AC 40 ms
47,400 KB
testcase_02 AC 43 ms
49,712 KB
testcase_03 AC 43 ms
49,512 KB
testcase_04 AC 75 ms
51,888 KB
testcase_05 AC 44 ms
49,452 KB
testcase_06 AC 48 ms
49,432 KB
testcase_07 AC 75 ms
52,276 KB
testcase_08 AC 114 ms
53,628 KB
testcase_09 AC 162 ms
52,924 KB
testcase_10 AC 241 ms
53,200 KB
testcase_11 AC 350 ms
55,972 KB
testcase_12 AC 361 ms
55,696 KB
testcase_13 AC 1,332 ms
55,764 KB
testcase_14 AC 1,222 ms
55,704 KB
testcase_15 AC 1,444 ms
55,740 KB
testcase_16 AC 1,344 ms
55,836 KB
testcase_17 AC 1,295 ms
55,836 KB
testcase_18 AC 209 ms
53,172 KB
testcase_19 AC 1,107 ms
56,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int p = sc.nextInt();
        int[] current = new int[n * 3 + 1];
        int[] next = new int[n * 3 + 1];
        Arrays.fill(current, Integer.MAX_VALUE / 2);
        current[0] = n;
        for (int i = 0; i < n; i++) {
            int[] scores = new int[4];
            for (int j = 0; j < 3; j++) {
                scores[j] = sc.nextInt() - 1;
            }
            Arrays.fill(next, Integer.MAX_VALUE / 2);
            for (int j = 0; j + 3 <= n * 3; j++) {
                for (int k = 0; k < 4; k++) {
                    next[j + k] = Math.min(next[j + k], current[j] + scores[k]);
                }
            }
            int[] tmp = current;
            current = next;
            next = tmp;
        }
        System.out.println(current[p] / (double)n);
    }
    
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0