結果

問題 No.143 豆
ユーザー kameyama_s
提出日時 2023-04-28 14:30:11
言語 Java
(openjdk 23)
結果
AC  
実行時間 145 ms / 1,000 ms
コード長 525 bytes
コンパイル時間 2,133 ms
コンパイル使用メモリ 74,240 KB
実行使用メモリ 41,668 KB
最終ジャッジ日時 2024-11-17 14:48:11
合計ジャッジ時間 5,326 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
		
		for(int i = 0; i<c; i++){
			int d = sc.nextInt();
			eatSumBeans= eatSumBeans+d;
		}
		int result = sumBeans - eatSumBeans;
		if(result <= -1){
			System.out.println(-1);
		}else{
        	System.out.println(result);
		}
    }
}
0