結果

問題 No.914 Omiyage
ユーザー tomomo2b2tomomo2b2
提出日時 2019-10-25 21:36:59
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 1,221 bytes
コンパイル時間 2,900 ms
コンパイル使用メモリ 110,148 KB
実行使用メモリ 26,180 KB
最終ジャッジ日時 2023-10-24 21:12:55
合計ジャッジ時間 4,212 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
26,172 KB
testcase_01 AC 30 ms
26,172 KB
testcase_02 AC 30 ms
26,180 KB
testcase_03 AC 31 ms
26,172 KB
testcase_04 AC 30 ms
26,172 KB
testcase_05 AC 29 ms
26,168 KB
testcase_06 AC 29 ms
26,168 KB
testcase_07 AC 29 ms
26,168 KB
testcase_08 AC 30 ms
26,172 KB
testcase_09 AC 29 ms
26,168 KB
testcase_10 AC 29 ms
26,172 KB
testcase_11 AC 31 ms
26,172 KB
testcase_12 AC 31 ms
26,172 KB
testcase_13 AC 31 ms
26,172 KB
testcase_14 AC 31 ms
26,172 KB
testcase_15 AC 30 ms
26,172 KB
testcase_16 AC 30 ms
26,172 KB
testcase_17 AC 30 ms
26,172 KB
testcase_18 AC 30 ms
26,172 KB
testcase_19 AC 30 ms
26,180 KB
testcase_20 AC 30 ms
26,172 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;
using System.IO;

class MyClass
{
    public static void Solve()
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var N = input[0];
        var M = input[1];
        var K = input[2];
        var sets = new HashSet<int>[N + 1];
        for (int i = 0; i < N + 1; i++)
        {
            sets[i] = new HashSet<int>();
        }
        sets[0].Add(0);
        for (int i = 0; i < N; i++)
        {
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            foreach (var item in sets[i])
            {
                for (int j = 0; j < M; j++)
                {
                    sets[i + 1].Add(item + A[j]);
                }
            }
        }
        var valid = sets[N].Where(x => x <= K);
        if (valid.Count() == 0)
        {
            Console.WriteLine(-1);
        }
        else
        {
            Console.WriteLine(K - valid.Max());
        }
    }

    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
0