結果

問題 No.2424 Josouzai
ユーザー tentententen
提出日時 2023-08-23 13:56:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 382 ms / 2,000 ms
コード長 1,928 bytes
コンパイル時間 4,087 ms
コンパイル使用メモリ 93,116 KB
実行使用メモリ 62,668 KB
最終ジャッジ日時 2023-08-23 13:56:32
合計ジャッジ時間 18,830 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
52,364 KB
testcase_01 AC 74 ms
53,068 KB
testcase_02 AC 92 ms
52,696 KB
testcase_03 AC 76 ms
52,712 KB
testcase_04 AC 262 ms
58,012 KB
testcase_05 AC 370 ms
62,068 KB
testcase_06 AC 382 ms
62,668 KB
testcase_07 AC 382 ms
62,308 KB
testcase_08 AC 371 ms
62,404 KB
testcase_09 AC 75 ms
52,820 KB
testcase_10 AC 232 ms
57,784 KB
testcase_11 AC 284 ms
59,892 KB
testcase_12 AC 269 ms
59,420 KB
testcase_13 AC 257 ms
58,360 KB
testcase_14 AC 299 ms
60,392 KB
testcase_15 AC 182 ms
56,592 KB
testcase_16 AC 353 ms
59,744 KB
testcase_17 AC 251 ms
58,120 KB
testcase_18 AC 259 ms
58,088 KB
testcase_19 AC 274 ms
58,452 KB
testcase_20 AC 353 ms
60,156 KB
testcase_21 AC 323 ms
60,204 KB
testcase_22 AC 260 ms
58,496 KB
testcase_23 AC 254 ms
58,248 KB
testcase_24 AC 219 ms
57,864 KB
testcase_25 AC 367 ms
62,440 KB
testcase_26 AC 324 ms
60,368 KB
testcase_27 AC 375 ms
62,596 KB
testcase_28 AC 346 ms
60,232 KB
testcase_29 AC 334 ms
59,556 KB
testcase_30 AC 227 ms
58,164 KB
testcase_31 AC 290 ms
59,192 KB
testcase_32 AC 366 ms
62,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    static ArrayList<HashMap<Long, Long>> dp = new ArrayList<>();
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = sc.nextInt();
        }
        Arrays.sort(values);
        for (int i = 0; i < n; i++) {
            if (k < values[i]) {
                System.out.println(i + " " + k);
                return;
            }
            k -= values[i];
        }
        System.out.println(n + " " + k);
    }
} 
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