提出 #72532010


ソースコード 拡げる

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

public class Main {

	public static void main(String[] args) throws IOException{
		Scanner s = new Scanner(System.in);


		int n =s.nextInt();
		int k = s.nextInt();
		long x= s.nextLong();
		long[] arr = new long[n];
		for(int i = 0 ;i<n; i++ ){
			arr[i] = s.nextLong(); 
		}
		Arrays.sort(arr);
		long p = 0;
		int min = 0;
		for(int i = k-1; i>=0; i--){
			p+=arr[i];
			min++;
			if (p>=x) {
				break;
			}
		}
		System.out.println( p>=x? min+(n-k): -1);


	}
} 

提出情報

提出日時
問題 C - Sake or Water
ユーザ Reuben9027
言語 Java24 (OpenJDK 24.0.2)
得点 300
コード長 539 Byte
結果 AC
実行時間 545 ms
メモリ 71140 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 33
セット名 テストケース
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 78 ms 40492 KiB
example_01.txt AC 69 ms 40224 KiB
example_02.txt AC 68 ms 40452 KiB
hand_00.txt AC 468 ms 70416 KiB
hand_01.txt AC 469 ms 69632 KiB
hand_02.txt AC 508 ms 69552 KiB
hand_03.txt AC 489 ms 70284 KiB
hand_04.txt AC 496 ms 71140 KiB
hand_05.txt AC 494 ms 69592 KiB
hand_06.txt AC 485 ms 70332 KiB
hand_07.txt AC 71 ms 40900 KiB
hand_08.txt AC 71 ms 41100 KiB
hand_09.txt AC 68 ms 40436 KiB
hand_10.txt AC 69 ms 40500 KiB
hand_11.txt AC 469 ms 70180 KiB
random_00.txt AC 524 ms 70012 KiB
random_01.txt AC 527 ms 69916 KiB
random_02.txt AC 544 ms 70224 KiB
random_03.txt AC 528 ms 70052 KiB
random_04.txt AC 523 ms 69944 KiB
random_05.txt AC 532 ms 70008 KiB
random_06.txt AC 545 ms 69632 KiB
random_07.txt AC 535 ms 69912 KiB
random_08.txt AC 519 ms 70312 KiB
random_09.txt AC 528 ms 70056 KiB
random_10.txt AC 525 ms 70048 KiB
random_11.txt AC 537 ms 70132 KiB
random_12.txt AC 536 ms 70384 KiB
random_13.txt AC 542 ms 69692 KiB
random_14.txt AC 534 ms 70392 KiB
random_15.txt AC 526 ms 70004 KiB
random_16.txt AC 533 ms 70148 KiB
random_17.txt AC 532 ms 69672 KiB