結果

問題 No.914 Omiyage
ユーザー suikameron1suikameron1
提出日時 2019-10-25 22:06:15
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 1,084 bytes
コンパイル時間 784 ms
コンパイル使用メモリ 106,836 KB
実行使用メモリ 24,112 KB
最終ジャッジ日時 2023-10-24 21:15:07
合計ジャッジ時間 2,091 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
24,108 KB
testcase_01 AC 25 ms
24,108 KB
testcase_02 AC 25 ms
24,112 KB
testcase_03 AC 25 ms
24,108 KB
testcase_04 AC 24 ms
24,108 KB
testcase_05 AC 24 ms
24,108 KB
testcase_06 AC 24 ms
24,108 KB
testcase_07 AC 25 ms
24,108 KB
testcase_08 AC 25 ms
24,108 KB
testcase_09 AC 25 ms
24,112 KB
testcase_10 AC 25 ms
24,108 KB
testcase_11 AC 24 ms
24,108 KB
testcase_12 AC 25 ms
24,108 KB
testcase_13 AC 25 ms
24,108 KB
testcase_14 AC 25 ms
24,108 KB
testcase_15 AC 25 ms
24,108 KB
testcase_16 AC 24 ms
24,108 KB
testcase_17 AC 24 ms
24,108 KB
testcase_18 AC 25 ms
24,108 KB
testcase_19 AC 24 ms
24,112 KB
testcase_20 AC 24 ms
24,108 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.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
    int k = int.Parse(input[2]);
    int[,] matrix = new int[n,m];//行列  
    for(int i = 0; i < n; i++)
    {
    	int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    	for(int j = 0; j < m; j++) matrix[i,j] = nums[j];
    }
    bool[,] dp = new bool[n+1,k+1];//x個見てy円残るか
    dp[0,k] = true;

    for(int x = 1; x <= n; x++)//見た国
    {
      for(int y = 0; y < m; y++)
      {
        for(int z = 0; z <= k; z++)
        {
          if(z+matrix[x-1,y] <= k)
          {
            if(dp[x-1,z+matrix[x-1,y]])
              dp[x,z] = true;
          }
        }
      }
    }

    for(int i = 0; i <= k; i++)
    {
      if(dp[n,i])
      {
        Console.WriteLine(i);
        break;
      }else if(i == k) Console.WriteLine(-1);
    }
	}
}
0