結果

問題 No.5 数字のブロック
ユーザー ToniTakekawaToniTakekawa
提出日時 2015-07-24 19:25:05
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 79 ms / 5,000 ms
コード長 1,353 bytes
コンパイル時間 2,716 ms
コンパイル使用メモリ 108,936 KB
実行使用メモリ 24,548 KB
最終ジャッジ日時 2023-08-11 08:34:35
合計ジャッジ時間 6,510 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
21,788 KB
testcase_01 AC 65 ms
19,768 KB
testcase_02 AC 64 ms
23,784 KB
testcase_03 AC 77 ms
22,260 KB
testcase_04 AC 75 ms
22,260 KB
testcase_05 AC 78 ms
24,372 KB
testcase_06 AC 76 ms
22,424 KB
testcase_07 AC 76 ms
24,192 KB
testcase_08 AC 77 ms
24,432 KB
testcase_09 AC 73 ms
22,160 KB
testcase_10 AC 78 ms
24,548 KB
testcase_11 AC 76 ms
22,124 KB
testcase_12 AC 76 ms
22,300 KB
testcase_13 AC 77 ms
22,404 KB
testcase_14 AC 64 ms
21,864 KB
testcase_15 AC 72 ms
24,008 KB
testcase_16 AC 77 ms
22,480 KB
testcase_17 AC 78 ms
22,440 KB
testcase_18 AC 79 ms
24,456 KB
testcase_19 AC 79 ms
22,572 KB
testcase_20 AC 64 ms
21,732 KB
testcase_21 AC 66 ms
23,852 KB
testcase_22 AC 66 ms
21,796 KB
testcase_23 AC 64 ms
21,768 KB
testcase_24 AC 72 ms
21,992 KB
testcase_25 AC 73 ms
19,936 KB
testcase_26 AC 65 ms
23,776 KB
testcase_27 AC 65 ms
23,720 KB
testcase_28 AC 63 ms
21,916 KB
testcase_29 AC 75 ms
22,112 KB
testcase_30 AC 73 ms
20,044 KB
testcase_31 AC 62 ms
21,784 KB
testcase_32 AC 64 ms
21,720 KB
testcase_33 AC 63 ms
23,840 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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