結果

問題 No.143 豆
ユーザー n.yn.y
提出日時 2022-05-27 09:21:03
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 25 ms / 1,000 ms
コード長 1,099 bytes
コンパイル時間 1,798 ms
コンパイル使用メモリ 107,384 KB
実行使用メモリ 24,148 KB
最終ジャッジ日時 2023-10-20 19:38:21
合計ジャッジ時間 1,912 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
24,144 KB
testcase_01 AC 22 ms
24,148 KB
testcase_02 AC 23 ms
24,144 KB
testcase_03 AC 22 ms
24,144 KB
testcase_04 AC 22 ms
24,144 KB
testcase_05 AC 24 ms
24,148 KB
testcase_06 AC 22 ms
24,148 KB
testcase_07 AC 23 ms
24,148 KB
testcase_08 AC 22 ms
24,148 KB
testcase_09 AC 23 ms
24,144 KB
testcase_10 AC 23 ms
24,148 KB
testcase_11 AC 24 ms
24,144 KB
testcase_12 AC 24 ms
24,144 KB
testcase_13 AC 24 ms
24,144 KB
testcase_14 AC 24 ms
24,144 KB
testcase_15 AC 23 ms
24,144 KB
testcase_16 AC 22 ms
24,144 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace yukicoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            //一袋豆の数
            int K = int.Parse(str[0]);
            //袋の数
            int N = int.Parse(str[1]);
            //何人家族
            int F = int.Parse(str[2]);

            string[] old = Console.ReadLine().Split(' ');
            int[] a = new int[old.Length];

            //家族の各年齢
            for (int i = 0; i < old.Length; i++)
            {
                int A = int.Parse(old[i]);
                a[i] = A;
            }

            //豆の合計
            int m = K * N;

            //豆の合計から年齢引く
            for (int i=0;i<old.Length;i++)
            {
                m = m - a[i];
            }
            //年齢より豆の数が少なければ -1
            if (m < 0)
            {
                Console.WriteLine(-1);

            }
            else
            {
                Console.WriteLine(m);
            }
        }
    }
}
0