結果

問題 No.5 数字のブロック
ユーザー solitarywalker
提出日時 2019-05-18 22:16:31
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 718 bytes
コンパイル時間 3,818 ms
コンパイル使用メモリ 105,984 KB
実行使用メモリ 20,352 KB
最終ジャッジ日時 2024-09-17 06:23:26
合計ジャッジ時間 6,028 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.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            var maxWidth = int.Parse(Console.ReadLine());
            var blockNumber = int.Parse(Console.ReadLine());
            var blocks = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
            blocks.Sort();
            int sumWidth = 0, i = 0;
            foreach(int block in blocks) {
                sumWidth += block;
                if(maxWidth < sumWidth)
                    break;
                i++;
            }
            Console.WriteLine(i);
        }
    }
}

0