結果

問題 No.617 Nafmo、買い出しに行く
ユーザー mbanmban
提出日時 2017-12-17 05:43:13
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 2,148 bytes
コンパイル時間 4,252 ms
コンパイル使用メモリ 104,992 KB
実行使用メモリ 23,140 KB
最終ジャッジ日時 2023-08-21 13:10:43
合計ジャッジ時間 5,537 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
20,732 KB
testcase_01 AC 67 ms
20,716 KB
testcase_02 AC 93 ms
20,728 KB
testcase_03 AC 112 ms
20,860 KB
testcase_04 AC 78 ms
20,672 KB
testcase_05 AC 117 ms
23,140 KB
testcase_06 AC 123 ms
20,660 KB
testcase_07 AC 122 ms
20,604 KB
testcase_08 AC 61 ms
20,736 KB
testcase_09 AC 65 ms
20,724 KB
testcase_10 AC 127 ms
20,936 KB
testcase_11 AC 131 ms
18,852 KB
testcase_12 AC 129 ms
21,224 KB
testcase_13 AC 130 ms
23,140 KB
testcase_14 AC 130 ms
18,932 KB
testcase_15 AC 127 ms
23,012 KB
testcase_16 AC 126 ms
20,952 KB
testcase_17 AC 129 ms
22,708 KB
testcase_18 AC 61 ms
22,704 KB
testcase_19 AC 60 ms
20,756 KB
testcase_20 AC 63 ms
20,668 KB
testcase_21 AC 72 ms
22,968 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;
using System.Text;
using System.Threading.Tasks;

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public string[] StringArray()
    {
        Line = Console.ReadLine().Split(Separator);
        Index = Line.Length;
        return Line;
    }

    public int[] IntArray()
    {
        var l = StringArray();
        var res = new int[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = int.Parse(l[i]);
        }
        return res;
    }

    public long[] LongArray()
    {
        var l = StringArray();
        var res = new long[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = long.Parse(l[i]);
        }
        return res;
    }
}

class Program
{
    private int N, K;
    private int[] A;
    private void Scan()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();
        A = new int[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = sc.NextInt();
        }
    }

    public void Solve()
    {
        Scan();
        var b = new bool[2000001];
        b[0] = true;
        for (int j = 0; j < N; j++)
        {
            for (int i = 2000000; i >= 0; i--)
            {
                if (b[i] && i + A[j] <= 2000000)
                {
                    b[i + A[j]] = true;
                }
            }
        }
        for (int i = K; ; i--)
        {
            if (b[i])
            {
                Console.WriteLine(i);
                return;
            }
        }
    }

    static void Main(string[] args)
    {
        new Program().Solve();
    }
}
0