結果
| 問題 | No.1046 Fruits Rush |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-22 18:00:23 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 847 bytes |
| 記録 | |
| コンパイル時間 | 2,205 ms |
| コンパイル使用メモリ | 74,180 KB |
| 実行使用メモリ | 41,752 KB |
| 最終ジャッジ日時 | 2024-09-26 07:35:20 |
| 合計ジャッジ時間 | 4,934 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 3 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
int[] juices = new int[n];
for(int i = 0 ; i < n ; i++){
juices[i] = sc.nextInt();
}
int ans = 0;
for(int i = 0 ; i < k ; i++){
int max = 0;
int index = -1;
for(int j = 0 ; j < n ; j++){
if(juices[j] > max){
max = juices[j];
index = j;
}
}
if(max == 0){
break;
}
ans += max;
juices[index] = -101;
}
System.out.println(ans);
}
}