結果
| 問題 |
No.143 豆
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-11 10:26:33 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 1,000 ms |
| コード長 | 822 bytes |
| コンパイル時間 | 7,995 ms |
| コンパイル使用メモリ | 170,284 KB |
| 実行使用メモリ | 29,468 KB |
| 最終ジャッジ日時 | 2025-11-11 10:26:44 |
| 合計ジャッジ時間 | 10,182 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (145 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System;
public class Program
{
public static void Main()
{
//int one = int.Parse(Console.ReadLine() ?? string.Empty);
string[] num = (Console.ReadLine() ?? string.Empty).Trim().Split(' ');
string[] age = (Console.ReadLine() ?? string.Empty).Trim().Split(' ');
int family = int.Parse(num[2]); //家族の数
int sum = int.Parse(num[0]) * int.Parse(num[1]); //豆個数
int need = 0;
for (int i = 0; i< family; i++)
{
need += int.Parse(age[i]);
if(sum < need)
{
Console.WriteLine("-1");
return;
}
}
//Console.WriteLine("必要個数 {0}",need);
//Console.WriteLine("豆個数 {0}",sum);
Console.WriteLine("{0}",sum-need);
}
}