結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2017-12-25 21:50:38 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 851 bytes |
コンパイル時間 | 1,160 ms |
コンパイル使用メモリ | 114,484 KB |
実行使用メモリ | 29,920 KB |
最終ジャッジ日時 | 2024-12-17 20:14:56 |
合計ジャッジ時間 | 3,655 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 WA * 7 |
コンパイルメッセージ
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; namespace BlocksIn { class MainClass { public static void Main(string[] args) { int m = 0; int n = 0; string M = Console.ReadLine(); string N = Console.ReadLine(); bool flgM = int.TryParse(M, out m); bool flgN = int.TryParse(N, out n); if (!flgM || m == 0) { Console.WriteLine("Erorr WidthSize"); return; } if (!flgN || n == 0) { Console.WriteLine("Erorr WidthSize"); return; } List<int> blocks = new List<int>(); string Blocks = Console.ReadLine(); string[] blks = Blocks.Split(new char[] { ' ' }); for (int i = 0; i < n; i++) { blocks.Add(int.Parse(blks[i])); } int all = 0; List<int> res = blocks.OrderBy(x => x).Where(x => (all += x) < m).ToList(); Console.WriteLine(res.Count); } } }