結果
問題 | No.143 豆 |
ユーザー | Gchansanjou |
提出日時 | 2018-02-11 18:32:27 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 45 ms / 1,000 ms |
コード長 | 1,138 bytes |
コンパイル時間 | 3,392 ms |
コンパイル使用メモリ | 74,040 KB |
実行使用メモリ | 49,524 KB |
最終ジャッジ日時 | 2023-09-30 17:12:11 |
合計ジャッジ時間 | 5,220 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
49,356 KB |
testcase_01 | AC | 45 ms
49,044 KB |
testcase_02 | AC | 45 ms
49,524 KB |
testcase_03 | AC | 44 ms
48,996 KB |
testcase_04 | AC | 44 ms
49,180 KB |
testcase_05 | AC | 44 ms
49,376 KB |
testcase_06 | AC | 44 ms
49,216 KB |
testcase_07 | AC | 44 ms
49,148 KB |
testcase_08 | AC | 44 ms
49,220 KB |
testcase_09 | AC | 45 ms
49,176 KB |
testcase_10 | AC | 44 ms
49,136 KB |
testcase_11 | AC | 44 ms
49,124 KB |
testcase_12 | AC | 43 ms
49,004 KB |
testcase_13 | AC | 45 ms
49,516 KB |
testcase_14 | AC | 45 ms
49,464 KB |
testcase_15 | AC | 45 ms
49,220 KB |
testcase_16 | AC | 44 ms
49,180 KB |
ソースコード
package yukiCoder; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class No00143 { public static void main(String[] args) { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); String[] input1 = new String[3]; try { input1 = bufferedReader.readLine().split(" "); int[] input2 = new int[Integer.parseInt(input1[2])]; input2 = toIntArray(bufferedReader.readLine().split(" ")); int fullBeans = Integer.parseInt(input1[0]) * Integer.parseInt(input1[1]); System.out.println(eatFamily(fullBeans, input2)); } catch (IOException e) { e.printStackTrace(); } } public static int[] toIntArray(String[] stringArray) { int[] intArray = new int[stringArray.length]; for (int i = 0 ; i < stringArray.length ; i++) { intArray[i] = Integer.parseInt(stringArray[i]); } return intArray; } public static int eatFamily(int fullBeans, int[] ageArray) { for (int i = 0 ; i < ageArray.length ; i++) { fullBeans -= ageArray[i]; if (Integer.signum(fullBeans) == -1) { return -1; } } return fullBeans; } }