結果
問題 |
No.143 豆
|
ユーザー |
|
提出日時 | 2022-05-27 09:21:03 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 25 ms / 1,000 ms |
コード長 | 1,099 bytes |
コンパイル時間 | 1,191 ms |
コンパイル使用メモリ | 103,296 KB |
実行使用メモリ | 17,920 KB |
最終ジャッジ日時 | 2024-09-20 15:11:28 |
合計ジャッジ時間 | 1,941 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; namespace yukicoder { class Program { static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); //一袋豆の数 int K = int.Parse(str[0]); //袋の数 int N = int.Parse(str[1]); //何人家族 int F = int.Parse(str[2]); string[] old = Console.ReadLine().Split(' '); int[] a = new int[old.Length]; //家族の各年齢 for (int i = 0; i < old.Length; i++) { int A = int.Parse(old[i]); a[i] = A; } //豆の合計 int m = K * N; //豆の合計から年齢引く for (int i=0;i<old.Length;i++) { m = m - a[i]; } //年齢より豆の数が少なければ -1 if (m < 0) { Console.WriteLine(-1); } else { Console.WriteLine(m); } } } }