結果
| 問題 |
No.143 豆
|
| コンテスト | |
| ユーザー |
Gchansanjou
|
| 提出日時 | 2018-02-11 18:32:27 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 56 ms / 1,000 ms |
| コード長 | 1,138 bytes |
| コンパイル時間 | 3,360 ms |
| コンパイル使用メモリ | 76,864 KB |
| 実行使用メモリ | 50,396 KB |
| 最終ジャッジ日時 | 2024-07-23 10:54:27 |
| 合計ジャッジ時間 | 4,870 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
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;
}
}
Gchansanjou