結果
問題 | No.143 豆 |
ユーザー |
![]() |
提出日時 | 2015-02-08 12:46:17 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 133 ms / 1,000 ms |
コード長 | 692 bytes |
コンパイル時間 | 3,244 ms |
コンパイル使用メモリ | 75,196 KB |
実行使用メモリ | 54,256 KB |
最終ジャッジ日時 | 2024-07-23 10:16:21 |
合計ジャッジ時間 | 6,176 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
package P361; import java.util.Scanner; public class P361 { public static void main(String args[]){ Scanner sc = new Scanner(System.in); String r = sc.nextLine(); String[] rstrs = r.split(" ",0); String s = sc.nextLine(); String[] sstrs = s.split(" ",0); int k = Integer.parseInt(rstrs[0]); int n = Integer.parseInt(rstrs[1]); int f = Integer.parseInt(rstrs[2]); int[] a = new int[f]; int sumk = k * n; int needk = 0; for (int i=0;i<f;i++) { a[i] = Integer.parseInt(sstrs[i]); needk += a[i]; } int ans = 0; if (sumk < needk) { ans = -1; } else if (sumk >= needk) { ans = sumk - needk; } System.out.println(ans); } }