結果

問題 No.914 Omiyage
ユーザー tsushimatsushima
提出日時 2019-10-26 07:12:15
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 1,151 bytes
コンパイル時間 3,321 ms
コンパイル使用メモリ 110,056 KB
実行使用メモリ 25,108 KB
最終ジャッジ日時 2023-10-24 21:17:25
合計ジャッジ時間 2,531 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
25,104 KB
testcase_01 AC 26 ms
25,104 KB
testcase_02 AC 25 ms
25,108 KB
testcase_03 AC 25 ms
25,104 KB
testcase_04 AC 25 ms
25,104 KB
testcase_05 AC 25 ms
25,104 KB
testcase_06 AC 25 ms
25,104 KB
testcase_07 AC 24 ms
25,104 KB
testcase_08 AC 25 ms
25,104 KB
testcase_09 AC 25 ms
25,108 KB
testcase_10 AC 25 ms
25,104 KB
testcase_11 AC 25 ms
25,104 KB
testcase_12 AC 26 ms
25,104 KB
testcase_13 AC 25 ms
25,104 KB
testcase_14 AC 25 ms
25,104 KB
testcase_15 AC 25 ms
25,104 KB
testcase_16 AC 25 ms
25,104 KB
testcase_17 AC 25 ms
25,104 KB
testcase_18 AC 25 ms
25,104 KB
testcase_19 AC 26 ms
25,108 KB
testcase_20 AC 25 ms
25,104 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.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            // 写経
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], M = l[1], K = l[2];
            var A = new int[N][];
            for (var i = 0; i < N; i++) A[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var dp = new int[K + 1];
            dp[0] = 1;
            for (var i = 0; i < N; i++)
            {
                var tmp = new int[K + 1];
                for (var j = 0; j < M; j++)
                {
                    for (var k = 0; k + A[i][j] <= K; k++)
                    {
                        if (dp[k] > 0) tmp[k + A[i][j]] = 1;
                    }
                }
                dp = tmp;
            }

            for (var i = K; i >= 0; i--)
            {
                if (dp[i] > 0)
                {
                    Console.WriteLine(K - i);
                    return;
                }
            }

            Console.WriteLine(-1);
        }
    }
}
0