結果
| 問題 |
No.143 豆
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-21 09:50:33 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 1,000 ms |
| コード長 | 1,334 bytes |
| コンパイル時間 | 759 ms |
| コンパイル使用メモリ | 109,956 KB |
| 実行使用メモリ | 26,108 KB |
| 最終ジャッジ日時 | 2024-07-23 10:37:31 |
| 合計ジャッジ時間 | 1,802 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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());
}
}
}