結果

問題 No.2329 Nafmo、イカサマをする
ユーザー tentententen
提出日時 2023-05-30 15:17:44
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 2,163 bytes
コンパイル時間 3,577 ms
コンパイル使用メモリ 86,596 KB
実行使用メモリ 245,412 KB
最終ジャッジ日時 2023-08-28 00:39:16
合計ジャッジ時間 11,861 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,672 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 43 ms
49,632 KB
testcase_04 AC 43 ms
49,568 KB
testcase_05 AC 43 ms
49,428 KB
testcase_06 AC 44 ms
49,600 KB
testcase_07 RE -
testcase_08 AC 115 ms
55,036 KB
testcase_09 AC 44 ms
49,596 KB
testcase_10 AC 44 ms
49,912 KB
testcase_11 AC 46 ms
49,732 KB
testcase_12 AC 44 ms
49,676 KB
testcase_13 AC 49 ms
50,212 KB
testcase_14 AC 43 ms
49,548 KB
testcase_15 AC 44 ms
49,728 KB
testcase_16 AC 72 ms
53,404 KB
testcase_17 AC 43 ms
47,516 KB
testcase_18 AC 44 ms
49,444 KB
testcase_19 AC 149 ms
58,404 KB
testcase_20 AC 46 ms
49,616 KB
testcase_21 AC 47 ms
50,092 KB
testcase_22 AC 51 ms
50,336 KB
testcase_23 AC 46 ms
49,632 KB
testcase_24 AC 46 ms
49,620 KB
testcase_25 AC 49 ms
47,720 KB
testcase_26 AC 45 ms
49,548 KB
testcase_27 AC 46 ms
49,676 KB
testcase_28 AC 46 ms
49,384 KB
testcase_29 AC 182 ms
62,608 KB
testcase_30 AC 49 ms
49,772 KB
testcase_31 AC 46 ms
49,592 KB
testcase_32 RE -
testcase_33 AC 49 ms
49,552 KB
testcase_34 AC 46 ms
49,932 KB
testcase_35 AC 75 ms
52,176 KB
testcase_36 AC 935 ms
117,176 KB
testcase_37 AC 75 ms
52,368 KB
testcase_38 AC 80 ms
52,836 KB
testcase_39 AC 654 ms
90,032 KB
testcase_40 AC 482 ms
79,148 KB
testcase_41 TLE -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

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();
        long m = sc.nextLong();
        int k = sc.nextInt();
        ArrayList<TreeSet<Long>> dp = new ArrayList<>();
        for (int i = 0; i <= k; i++) {
            dp.add(new TreeSet<>());
        }
        dp.get(0).add(0L);
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            for (int j = 1; j <= k; j++) {
                for (long y : dp.get(j - 1)) {
                    if (x + y > m)  {
                        break;
                    }
                    dp.get(j).add(x + y);
                }
            }
        }
        long ans = 0;
        for (TreeSet<Long> set : dp) {
            ans = Math.max(ans, set.last());
        }
        System.out.println(ans);
    }
}

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