結果

問題 No.617 Nafmo、買い出しに行く
ユーザー NoNo
提出日時 2018-01-26 02:49:08
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 806 bytes
コンパイル時間 2,459 ms
コンパイル使用メモリ 102,468 KB
実行使用メモリ 31,432 KB
最終ジャッジ日時 2023-08-27 06:03:32
合計ジャッジ時間 5,185 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
21,724 KB
testcase_01 AC 58 ms
23,732 KB
testcase_02 AC 59 ms
23,724 KB
testcase_03 AC 63 ms
23,724 KB
testcase_04 AC 59 ms
21,716 KB
testcase_05 AC 62 ms
24,136 KB
testcase_06 AC 90 ms
29,400 KB
testcase_07 AC 90 ms
31,432 KB
testcase_08 AC 60 ms
21,668 KB
testcase_09 AC 60 ms
21,668 KB
testcase_10 AC 89 ms
29,352 KB
testcase_11 AC 91 ms
31,272 KB
testcase_12 AC 89 ms
29,204 KB
testcase_13 AC 88 ms
31,352 KB
testcase_14 AC 90 ms
27,204 KB
testcase_15 AC 80 ms
31,356 KB
testcase_16 AC 82 ms
29,204 KB
testcase_17 AC 82 ms
29,412 KB
testcase_18 AC 57 ms
21,752 KB
testcase_19 AC 60 ms
21,572 KB
testcase_20 AC 59 ms
21,668 KB
testcase_21 AC 60 ms
23,728 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.Linq;

namespace y
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            int k = int.Parse(ss[1]);
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }

            var li = new List<int>();
            li.Add(0);
            for (int i = 0; i < n; i++)
            {
                int c = li.Count;
                for (int j = 0; j < c; j++)
                {
                    li.Add(li[j] + a[i]);
                }
            }

            Console.WriteLine(li.Where(x => x <= k).Max());
        }
    }
}
0