結果

問題 No.5 数字のブロック
ユーザー fujic
提出日時 2017-12-25 21:52:59
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 45 ms / 5,000 ms
コード長 852 bytes
コンパイル時間 1,113 ms
コンパイル使用メモリ 115,096 KB
実行使用メモリ 28,380 KB
最終ジャッジ日時 2024-11-18 11:53:33
合計ジャッジ時間 3,322 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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);
		}
	}
}
0