結果

問題 No.143 豆
ユーザー _mi_lin__mi_lin_
提出日時 2019-04-05 10:07:03
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 58 ms / 1,000 ms
コード長 1,242 bytes
コンパイル時間 2,083 ms
コンパイル使用メモリ 101,776 KB
実行使用メモリ 20,924 KB
最終ジャッジ日時 2023-09-30 17:29:53
合計ジャッジ時間 3,921 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,852 KB
testcase_01 AC 56 ms
20,824 KB
testcase_02 AC 58 ms
20,812 KB
testcase_03 AC 58 ms
20,924 KB
testcase_04 AC 58 ms
20,868 KB
testcase_05 AC 56 ms
20,740 KB
testcase_06 AC 56 ms
20,700 KB
testcase_07 AC 56 ms
20,608 KB
testcase_08 AC 57 ms
20,600 KB
testcase_09 AC 57 ms
20,816 KB
testcase_10 AC 55 ms
18,808 KB
testcase_11 AC 57 ms
20,692 KB
testcase_12 AC 57 ms
20,800 KB
testcase_13 AC 57 ms
20,740 KB
testcase_14 AC 58 ms
20,772 KB
testcase_15 AC 57 ms
20,736 KB
testcase_16 AC 58 ms
20,696 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace No143Beans
{
    class Program
    {
        static void Main(string[] args)
        {
            //豆、袋、人数の入力
            string[] K = Console.ReadLine().Split(' ');

            int beans = int.Parse(K[0]);
            int pack = int.Parse(K[1]);
            int people = int.Parse(K[2]);

            //年齢の入力
            string[] N = Console.ReadLine().Split(' ');

            //豆の総数
            int allbeans = (beans * pack);

            //年齢の総数
            int[] year = new int[people];

            int years = 0;
            for (int i = 0; i < people; i++)
            {
                year[i] = int.Parse(N[i]);
                years += year[i];

            }

            //豆の数のほうが多い場合
            if (allbeans >= years)
            {
                //表示
                Console.WriteLine(allbeans - years);
            }

            //年齢の数のほうが大きい場合
            else if (years > allbeans)
            {
                //表示
                Console.WriteLine("-1");
            }
        }
    }
}
0