結果

問題 No.2329 Nafmo、イカサマをする
ユーザー tentententen
提出日時 2023-05-30 15:19:13
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 2,215 bytes
コンパイル時間 2,553 ms
コンパイル使用メモリ 82,256 KB
実行使用メモリ 245,856 KB
最終ジャッジ日時 2023-08-28 00:39:31
合計ジャッジ時間 11,567 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
38,808 KB
testcase_01 AC 42 ms
33,492 KB
testcase_02 AC 42 ms
33,632 KB
testcase_03 AC 41 ms
33,568 KB
testcase_04 AC 45 ms
33,664 KB
testcase_05 AC 43 ms
33,460 KB
testcase_06 AC 41 ms
33,416 KB
testcase_07 AC 43 ms
33,560 KB
testcase_08 AC 116 ms
39,432 KB
testcase_09 AC 47 ms
33,504 KB
testcase_10 AC 43 ms
33,460 KB
testcase_11 AC 47 ms
33,888 KB
testcase_12 AC 44 ms
33,496 KB
testcase_13 AC 49 ms
34,248 KB
testcase_14 AC 43 ms
33,644 KB
testcase_15 AC 42 ms
33,632 KB
testcase_16 AC 57 ms
35,068 KB
testcase_17 AC 42 ms
34,044 KB
testcase_18 AC 43 ms
33,504 KB
testcase_19 AC 138 ms
43,712 KB
testcase_20 AC 44 ms
33,676 KB
testcase_21 AC 46 ms
33,948 KB
testcase_22 AC 51 ms
34,096 KB
testcase_23 AC 46 ms
33,520 KB
testcase_24 AC 43 ms
33,504 KB
testcase_25 AC 49 ms
33,964 KB
testcase_26 AC 47 ms
33,684 KB
testcase_27 AC 45 ms
34,068 KB
testcase_28 AC 44 ms
33,564 KB
testcase_29 AC 183 ms
48,616 KB
testcase_30 AC 46 ms
34,148 KB
testcase_31 AC 44 ms
33,544 KB
testcase_32 AC 42 ms
33,504 KB
testcase_33 AC 47 ms
33,852 KB
testcase_34 AC 44 ms
33,664 KB
testcase_35 AC 76 ms
36,180 KB
testcase_36 AC 942 ms
101,116 KB
testcase_37 AC 81 ms
35,872 KB
testcase_38 AC 83 ms
35,644 KB
testcase_39 AC 683 ms
74,828 KB
testcase_40 AC 529 ms
65,420 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) {
            if (set.size() > 0) {
                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