結果

問題 No.5 数字のブロック
ユーザー ToniTakekawa
提出日時 2015-07-24 19:25:05
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 47 ms / 5,000 ms
コード長 1,353 bytes
コンパイル時間 2,554 ms
コンパイル使用メモリ 114,644 KB
実行使用メモリ 28,380 KB
最終ジャッジ日時 2024-11-17 23:02:15
合計ジャッジ時間 5,136 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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.IO;
using System.Linq;
using System.Text;

// No.5 数字のブロック
// http://yukicoder.me/problems/14
class Program
{
    static void Main(string[] args)
    {
        //var In = new StreamReader("C:\\Users\\tny2\\Desktop\\14-testcase\\test_in\\4.txt");
        var In = Console.In;

        var L = int.Parse(In.ReadLine());
        var N = int.Parse(In.ReadLine());
        var Wn = In.ReadLine()
                        .Split(' ')
                        .Select(w => int.Parse(w))
                        .OrderBy(w => w)
                        .ToArray();

        //--------------------------------------------
        // Nっていつも使わないなあ、と思うのはC#erだけなのだろうか。
        //--------------------------------------------

        // E | W  T | S
        // ----------------
        // 1 | 1  1 | 1
        // 2 | 2  3 | 1 2
        // 3 | 3  6 | 1 2 3
        // 4 | 4 10 | 1 2 3 4

        var E = Enumerable.Range(0, Wn.Count());
        var S = E.Select(e => Wn.Take(e));

        // var V = T.Where(t => t <= L).Count();
        var length = 0;
        var n = 0;
        foreach( var e in E )
        {
            length += Wn[e];
            if (length > L) break;
            n++;
        }

        Console.WriteLine(n);
    }
}
0