結果

問題 No.1046 Fruits Rush
ユーザー 水野嶺水野嶺
提出日時 2020-05-28 09:21:34
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 498 bytes
コンパイル時間 4,587 ms
コンパイル使用メモリ 72,536 KB
実行使用メモリ 56,540 KB
最終ジャッジ日時 2023-08-03 06:22:43
合計ジャッジ時間 5,714 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 118 ms
55,932 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 118 ms
56,032 KB
testcase_07 WA -
testcase_08 AC 125 ms
55,368 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 122 ms
53,720 KB
testcase_13 AC 125 ms
53,732 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class Main
{
	public static void main (String[] args) 
	{
		// 入力値の読み込み
		Scanner sc = new Scanner(System.in);
		int  n = sc.nextInt();
		int  k = sc.nextInt();
		int goukei =0;
		
		ArrayList<Integer> fr = new ArrayList<>();
		
		for(int i=0;i<n;i++){
			fr.add(sc.nextInt());
		}
		Collections.sort(fr);
		
		for(int i=0;i<k;i++){
			if(fr.get(i)>0){
			goukei += fr.get(i);
			}
		}
		System.out.println(goukei);
		
	}
}
0