結果
| 問題 |
No.914 Omiyage
|
| コンテスト | |
| ユーザー |
suikameron1
|
| 提出日時 | 2019-10-25 22:06:15 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 1,084 bytes |
| コンパイル時間 | 748 ms |
| コンパイル使用メモリ | 110,872 KB |
| 実行使用メモリ | 26,024 KB |
| 最終ジャッジ日時 | 2024-09-24 16:27:58 |
| 合計ジャッジ時間 | 1,863 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);
}
}
}
suikameron1