結果
問題 | No.1046 Fruits Rush |
ユーザー | kusagame12 |
提出日時 | 2023-11-22 18:06:14 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 160 ms / 2,000 ms |
コード長 | 927 bytes |
コンパイル時間 | 3,131 ms |
コンパイル使用メモリ | 74,252 KB |
実行使用メモリ | 58,212 KB |
最終ジャッジ日時 | 2023-11-22 18:06:22 |
合計ジャッジ時間 | 5,588 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 160 ms
57,772 KB |
testcase_01 | AC | 131 ms
57,728 KB |
testcase_02 | AC | 130 ms
57,684 KB |
testcase_03 | AC | 138 ms
57,780 KB |
testcase_04 | AC | 139 ms
57,776 KB |
testcase_05 | AC | 137 ms
57,816 KB |
testcase_06 | AC | 131 ms
57,676 KB |
testcase_07 | AC | 139 ms
57,804 KB |
testcase_08 | AC | 151 ms
56,772 KB |
testcase_09 | AC | 128 ms
57,848 KB |
testcase_10 | AC | 121 ms
57,696 KB |
testcase_11 | AC | 113 ms
56,684 KB |
testcase_12 | AC | 134 ms
57,976 KB |
testcase_13 | AC | 131 ms
57,828 KB |
testcase_14 | AC | 127 ms
57,956 KB |
testcase_15 | AC | 125 ms
58,212 KB |
testcase_16 | AC | 120 ms
57,700 KB |
ソースコード
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 = -101; int index = -1; for(int j = 0 ; j < n ; j++){ if(juices[j] > max){ max = juices[j]; index = j; } } if(max <= 0){ if(i == 0){ ans = max; } break; } ans += max; juices[index] = -101; } System.out.println(ans); } }