結果

問題 No.1046 Fruits Rush
ユーザー 水野嶺
提出日時 2020-05-27 16:49:55
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 500 bytes
コンパイル時間 2,092 ms
コンパイル使用メモリ 76,812 KB
実行使用メモリ 41,904 KB
最終ジャッジ日時 2024-10-13 03:42:22
合計ジャッジ時間 5,073 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 1 WA * 6 RE * 7
権限があれば一括ダウンロードができます

ソースコード

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=1;i<=n;i++){
			fr.add(sc.nextInt());
		}
		Collections.sort(fr);
		
		for(int i=1;i<=k;i++){
			if(fr.get(i)>0){
			goukei += fr.get(i);
			}
		}
		System.out.println(goukei);
		
	}
}
0