結果

問題 No.1046 Fruits Rush
ユーザー 水野嶺水野嶺
提出日時 2020-05-27 16:47:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 498 bytes
コンパイル時間 2,707 ms
コンパイル使用メモリ 86,920 KB
実行使用メモリ 54,400 KB
最終ジャッジ日時 2024-04-21 05:12:13
合計ジャッジ時間 5,415 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 104 ms
39,460 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 106 ms
40,460 KB
testcase_07 WA -
testcase_08 AC 122 ms
41,336 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 128 ms
41,592 KB
testcase_13 AC 126 ms
41,592 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