結果

問題 No.143 豆
コンテスト
ユーザー 大谷祐翔
提出日時 2025-11-10 16:22:08
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 30 ms / 1,000 ms
コード長 755 bytes
コンパイル時間 910 ms
コンパイル使用メモリ 110,384 KB
実行使用メモリ 26,660 KB
最終ジャッジ日時 2025-11-10 16:22:11
合計ジャッジ時間 2,414 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine()!.Split(' ');
        string[] inputAge = Console.ReadLine()!.Split(' ');

        int beanCount = int.Parse(input[0]);
        int bagCount = int.Parse(input[1]);
        int ageSum = 0;

        for (int i = 0; i < inputAge.Length; i++)
        {
            if (inputAge[i] != "")
            {
                int age = int.Parse(inputAge[i]);
                ageSum += age;
            }
        }

        int beanSum = beanCount * bagCount;
        int ans = beanSum - ageSum;

        if (ans >= 0)
        {
            Console.WriteLine(ans);
        }
        else
        {
            Console.WriteLine("-1");
        }
    }
}
0