結果
| 問題 | 
                            No.143 豆
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-04-28 14:25:34 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 578 bytes | 
| コンパイル時間 | 1,856 ms | 
| コンパイル使用メモリ | 74,168 KB | 
| 実行使用メモリ | 41,668 KB | 
| 最終ジャッジ日時 | 2024-11-17 14:46:44 | 
| 合計ジャッジ時間 | 4,680 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 16 WA * 1 | 
ソースコード
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
		int sumBeans = a*b;
		int c = sc.nextInt();
		int eatSumBeans = 0;
		int [] familyNumber = new int[c];
		
		for(int i = 0; i<familyNumber.length; i++){
			int d = sc.nextInt();
			eatSumBeans= eatSumBeans+d;
		}
		int result = sumBeans - eatSumBeans;
		if(result <= 0){
			System.out.println(-1);
		}else{
        	System.out.println(result);
		}
    }
}