結果

問題 No.914 Omiyage
コンテスト
ユーザー tsushima
提出日時 2019-10-25 21:38:22
言語 C#(csc)
(csc 3.9.0)
コンパイル:
csc -langversion:latest -unsafe -warn:0 -o+ /r:System.Numerics.dll _filename_ -out:a.exe
実行:
/usr/bin/mono a.exe
結果
TLE  
実行時間 -
コード長 980 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 693 ms
コンパイル使用メモリ 113,684 KB
実行使用メモリ 40,840 KB
最終ジャッジ日時 2026-04-03 11:31:12
合計ジャッジ時間 8,132 ms
ジャッジサーバーID
(参考情報)
judge4_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other TLE * 1 -- * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #
raw source code

using System;
using System.Linq;
using System.Collections.Generic;

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

            for (var i = 0; i < N; i++) A[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var ans = Dfs(0, 0);
            Console.WriteLine(ans == 0 ? -1 : K - ans);

        }

        static int Dfs(int n, int total)
        {
            if (n == N)
            {
                if (total <= K) return total;
                else return -1;
            }

            var max = 0;
            for (var i = 0; i < M; i++)
            {
                max = Math.Max(max, Dfs(n + 1, total + A[n][i]));
            }

            return max;
        }
    }
}
0