結果

問題 No.5 数字のブロック
ユーザー funakoshifunakoshi
提出日時 2019-06-20 10:48:50
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 410 ms / 5,000 ms
コード長 1,056 bytes
コンパイル時間 2,076 ms
コンパイル使用メモリ 99,908 KB
実行使用メモリ 23,352 KB
最終ジャッジ日時 2023-08-22 07:28:14
合計ジャッジ時間 8,683 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
20,664 KB
testcase_01 AC 56 ms
22,764 KB
testcase_02 AC 56 ms
22,736 KB
testcase_03 AC 200 ms
23,148 KB
testcase_04 AC 102 ms
21,212 KB
testcase_05 AC 276 ms
19,328 KB
testcase_06 AC 152 ms
21,192 KB
testcase_07 AC 128 ms
21,032 KB
testcase_08 AC 173 ms
23,200 KB
testcase_09 AC 78 ms
20,936 KB
testcase_10 AC 284 ms
23,320 KB
testcase_11 AC 117 ms
23,180 KB
testcase_12 AC 207 ms
21,160 KB
testcase_13 AC 249 ms
23,176 KB
testcase_14 AC 56 ms
20,808 KB
testcase_15 AC 62 ms
20,904 KB
testcase_16 AC 282 ms
23,248 KB
testcase_17 AC 372 ms
23,352 KB
testcase_18 AC 312 ms
21,308 KB
testcase_19 AC 410 ms
21,416 KB
testcase_20 AC 57 ms
22,768 KB
testcase_21 AC 55 ms
18,684 KB
testcase_22 AC 56 ms
22,712 KB
testcase_23 AC 54 ms
22,732 KB
testcase_24 AC 62 ms
20,864 KB
testcase_25 AC 63 ms
20,852 KB
testcase_26 AC 56 ms
20,688 KB
testcase_27 AC 56 ms
22,960 KB
testcase_28 AC 55 ms
20,720 KB
testcase_29 AC 101 ms
23,120 KB
testcase_30 AC 81 ms
21,008 KB
testcase_31 AC 55 ms
20,712 KB
testcase_32 AC 55 ms
22,736 KB
testcase_33 AC 54 ms
22,708 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
public class Program
{
    static void Main()
    {
        string l = Console.ReadLine();
        string n = Console.ReadLine();
        string w = Console.ReadLine();
        string[] t = w.Split(' ');
        int[] ary = new int[t.Length];
        int total = int.Parse(l);
        int num = int.Parse(n);
        int cnt = 0;
        for(int i=0;i<ary.Length;i++)
        {
            ary[i] = int.Parse(t[i]);
        }
        for (int i = 0; i < t.Length; i++)
        {
            
            for (int j = i + 1; j < t.Length; j++)
            {
                
                if (ary[j] < ary[i])
                {
                    int temp = ary[i];
                    ary[i] = ary[j];
                    ary[j] = temp;
                }
                
            }
            
        }
        for (int i = 0; i < num; i++)
        {
            total = total - ary[i];
            if (total < 0)
            {
                break;
            }
            cnt++;
        }
        Console.WriteLine(cnt);
    }
}
0