結果

問題 No.5 数字のブロック
ユーザー itok217
提出日時 2017-04-19 21:11:20
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 44 ms / 5,000 ms
コード長 433 bytes
コンパイル時間 890 ms
コンパイル使用メモリ 109,788 KB
実行使用メモリ 28,096 KB
最終ジャッジ日時 2024-11-18 11:00:01
合計ジャッジ時間 3,184 ms
ジャッジサーバーID
(参考情報)
judge2 / 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;

class Program {
    static void Main() {
        int L = int.Parse(Console.ReadLine());
        Console.ReadLine();
        var seq = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x);
        int sum = 0;
        int cnt = 0;
        foreach (var elem in seq) {
            sum += elem;
            if (sum > L) break;
            cnt++;
        }
        Console.WriteLine(cnt);
    }
}
0