結果

問題 No.143 豆
ユーザー eringi103eringi103
提出日時 2016-10-21 09:50:33
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 57 ms / 1,000 ms
コード長 1,334 bytes
コンパイル時間 1,955 ms
コンパイル使用メモリ 106,304 KB
実行使用メモリ 22,864 KB
最終ジャッジ日時 2023-09-30 16:52:44
合計ジャッジ時間 3,751 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,640 KB
testcase_01 AC 55 ms
20,780 KB
testcase_02 AC 57 ms
20,900 KB
testcase_03 AC 57 ms
22,740 KB
testcase_04 AC 57 ms
22,864 KB
testcase_05 AC 56 ms
20,716 KB
testcase_06 AC 56 ms
20,780 KB
testcase_07 AC 55 ms
18,664 KB
testcase_08 AC 56 ms
22,672 KB
testcase_09 AC 56 ms
18,644 KB
testcase_10 AC 56 ms
20,696 KB
testcase_11 AC 57 ms
20,684 KB
testcase_12 AC 57 ms
20,644 KB
testcase_13 AC 57 ms
22,760 KB
testcase_14 AC 56 ms
20,736 KB
testcase_15 AC 57 ms
20,632 KB
testcase_16 AC 57 ms
20,624 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;

public class Program
{
  static void Main()
  {
    string data = Console.ReadLine();
    string _age = Console.ReadLine();
    string Mame_ = "";
    string Fukuro_ = "";
    string Family_ = "";
    int i = 0;

    while (data.Substring(i, 1) != " ")
    {
        Mame_ = Mame_ + data.Substring(i, 1);
        i++;
    }
    i++;
    while (data.Substring(i, 1) != " ")
    {
        Fukuro_ = Fukuro_ + data.Substring(i, 1);
        i++;
    }
    Family_ = data.Substring(i + 1, 1);

    int Mame = Convert.ToInt32(Mame_);
    int Fukuro = Convert.ToInt32(Fukuro_);
    int Family = Convert.ToInt32(Family_);

    //豆の総数
    int Mame_Kei = Fukuro * Mame;

    //家族の年齢
    List<int> age = new List<int>();
    string age_ = "";

    for (int a = 0; a < _age.Length; a++)
    {
        if (_age.Substring(a, 1) != " ")
        {
            age_ = age_ + _age.Substring(a, 1);
        }
        else
        {
            age.Add(Convert.ToInt32(age_));
            age_ = "";
        }
    }

    age.Add(Convert.ToInt32(age_));

    for (int c = 0; c < age.Count; c++)
    {
        Mame_Kei = Mame_Kei - age[c];
    }
    if (Mame_Kei < 0)
    {
        Console.WriteLine("-1");
    }
    else
    {
        Console.WriteLine(Mame_Kei.ToString());
    }

  }
}
0