結果

問題 No.5 数字のブロック
ユーザー NetSeed
提出日時 2016-05-10 22:52:20
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 42 ms / 5,000 ms
コード長 642 bytes
コンパイル時間 939 ms
コンパイル使用メモリ 117,144 KB
実行使用メモリ 28,376 KB
最終ジャッジ日時 2024-11-18 08:35:10
合計ジャッジ時間 3,390 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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.Linq;

namespace TestBench
{

	internal class Program
	{
		public static int Val { get; set; } = 100;

		internal static void Main()
		{
			var l = int.Parse(Console.ReadLine());
			Console.ReadLine();
			var w =
				Console.ReadLine()
					.Split(' ')
					.Select(x => short.Parse(x))
					.OrderBy(x => x)
					.Select((width, index) => new {width, index}).ToArray();

			var accum = 0;
			var idx = 0;
			foreach (var elem in w)
			{
				var tmp = accum + elem.width;
				idx = elem.index+1;

				if (tmp > l)
				{
					idx--;
					break;
				}

				accum = tmp;
			}


			Console.WriteLine(idx);




		}
	}
}
0