結果

問題 No.1046 Fruits Rush
ユーザー 水野嶺
提出日時 2020-05-28 09:31:50
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 531 bytes
コンパイル時間 2,462 ms
コンパイル使用メモリ 86,036 KB
実行使用メモリ 41,744 KB
最終ジャッジ日時 2024-10-13 04:03:00
合計ジャッジ時間 4,893 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other WA * 14
権限があれば一括ダウンロードができます

ソースコード

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