結果

問題 No.143 豆
ユーザー bayashiko_rbayashiko_r
提出日時 2018-11-01 23:52:44
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 58 ms / 1,000 ms
コード長 1,199 bytes
コンパイル時間 3,542 ms
コンパイル使用メモリ 104,616 KB
実行使用メモリ 22,868 KB
最終ジャッジ日時 2023-09-30 17:23:14
合計ジャッジ時間 3,829 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
20,708 KB
testcase_01 AC 57 ms
20,804 KB
testcase_02 AC 57 ms
20,700 KB
testcase_03 AC 57 ms
18,764 KB
testcase_04 AC 57 ms
20,860 KB
testcase_05 AC 55 ms
20,704 KB
testcase_06 AC 56 ms
20,848 KB
testcase_07 AC 56 ms
20,596 KB
testcase_08 AC 56 ms
20,748 KB
testcase_09 AC 58 ms
20,740 KB
testcase_10 AC 57 ms
22,792 KB
testcase_11 AC 57 ms
18,488 KB
testcase_12 AC 57 ms
20,604 KB
testcase_13 AC 58 ms
22,868 KB
testcase_14 AC 58 ms
22,864 KB
testcase_15 AC 58 ms
22,768 KB
testcase_16 AC 57 ms
20,804 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 ConsoleApplication7 {
    class Program {
        static void Main(string[] args) {
            //一行目
            //入力
            string T = Console.ReadLine();
            string[] t = T.Split(' ');
            //数字の割り当て
            int K = int.Parse(t[0]);
            int N = int.Parse(t[1]);
            int F = int.Parse(t[2]);

            //二行目
            //入力
            string U = Console.ReadLine();
            string[] u = U.Split(' ');
            //数字の割り当て
            int[] A = new int[F];
            for (int i = 0; i < F; i++) {
                A[i] = int.Parse(u[i]);
            }

            //全体の豆の数
            int all = K * N;

            //全体の消費数
            int consume = 0;
            for (int i = 0; i < F; i++) {
                consume += A[i];
            }

            //出力
            if ((all - consume) < 0) {
                Console.WriteLine("-1");
            } else {
                Console.WriteLine(all - consume);
            }
        }
    }
}
0