結果
問題 | No.143 豆 |
ユーザー | kazapyon27 |
提出日時 | 2017-05-06 14:26:46 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 138 ms / 1,000 ms |
コード長 | 808 bytes |
コンパイル時間 | 4,072 ms |
コンパイル使用メモリ | 72,600 KB |
実行使用メモリ | 56,132 KB |
最終ジャッジ日時 | 2023-09-30 17:01:56 |
合計ジャッジ時間 | 7,479 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 127 ms
55,488 KB |
testcase_01 | AC | 134 ms
55,700 KB |
testcase_02 | AC | 134 ms
55,760 KB |
testcase_03 | AC | 134 ms
55,864 KB |
testcase_04 | AC | 135 ms
55,792 KB |
testcase_05 | AC | 138 ms
55,608 KB |
testcase_06 | AC | 135 ms
55,640 KB |
testcase_07 | AC | 136 ms
55,532 KB |
testcase_08 | AC | 137 ms
55,520 KB |
testcase_09 | AC | 137 ms
56,060 KB |
testcase_10 | AC | 136 ms
55,692 KB |
testcase_11 | AC | 133 ms
55,804 KB |
testcase_12 | AC | 136 ms
55,868 KB |
testcase_13 | AC | 138 ms
55,772 KB |
testcase_14 | AC | 136 ms
55,808 KB |
testcase_15 | AC | 137 ms
56,132 KB |
testcase_16 | AC | 126 ms
55,780 KB |
ソースコード
/*No.143 豆*/ import java.util.*; public class No143 { public static void main(String[] args) { byte family,age_eat=0; short tsubu,fukuro; int mame; try(Scanner input = new Scanner(System.in)){ tsubu=input.nextShort(); fukuro=input.nextShort(); family=input.nextByte(); byte age[]=new byte[family]; for(byte i=0;i<age.length;i++){ age[i]=input.nextByte(); } Arrays.sort(age); mame=tsubu*fukuro; for(byte j=0;j<age.length;j++){ if(mame<age[j]){ mame=0; break; }else if(mame==age[j]){ mame=0; age_eat++; break; }else if(mame>age[j]){ mame-=age[j]; age_eat++; } } if(age_eat!=family){ System.out.println(-1); }else{ System.out.println(mame); } }catch(Exception e){ e.printStackTrace(); } } }