結果
| 問題 |
No.143 豆
|
| コンテスト | |
| ユーザー |
_mi_lin_
|
| 提出日時 | 2019-04-05 10:07:03 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 1,000 ms |
| コード長 | 1,242 bytes |
| コンパイル時間 | 846 ms |
| コンパイル使用メモリ | 112,284 KB |
| 実行使用メモリ | 28,172 KB |
| 最終ジャッジ日時 | 2024-07-23 11:11:43 |
| 合計ジャッジ時間 | 1,826 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
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");
}
}
}
}
_mi_lin_