結果

問題 No.1046 Fruits Rush
ユーザー 水野嶺水野嶺
提出日時 2020-05-28 09:31:50
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 531 bytes
コンパイル時間 2,297 ms
コンパイル使用メモリ 73,876 KB
実行使用メモリ 57,880 KB
最終ジャッジ日時 2023-08-03 06:24:08
合計ジャッジ時間 5,663 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 128 ms
55,508 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
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, Collections.reverseOrder());
		
		for(int i=0;i<k;i++){
			if(i>0&&fr.get(i)>0){
			goukei += fr.get(i);
			}
		}
		System.out.println(goukei);
		
	}
}
0