結果

問題 No.37 遊園地のアトラクション
ユーザー nanophoto12nanophoto12
提出日時 2014-11-02 13:04:53
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 33 ms / 5,000 ms
コード長 786 bytes
コンパイル時間 2,448 ms
コンパイル使用メモリ 111,972 KB
実行使用メモリ 29,304 KB
最終ジャッジ日時 2024-04-18 19:27:46
合計ジャッジ時間 4,142 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
25,108 KB
testcase_01 AC 28 ms
25,360 KB
testcase_02 AC 29 ms
27,272 KB
testcase_03 AC 29 ms
25,364 KB
testcase_04 AC 28 ms
29,304 KB
testcase_05 AC 28 ms
25,364 KB
testcase_06 AC 29 ms
25,136 KB
testcase_07 AC 30 ms
25,108 KB
testcase_08 AC 28 ms
25,132 KB
testcase_09 AC 25 ms
25,360 KB
testcase_10 AC 31 ms
25,128 KB
testcase_11 AC 31 ms
25,356 KB
testcase_12 AC 29 ms
27,292 KB
testcase_13 AC 29 ms
23,220 KB
testcase_14 AC 28 ms
25,384 KB
testcase_15 AC 29 ms
24,984 KB
testcase_16 AC 31 ms
23,092 KB
testcase_17 AC 29 ms
25,360 KB
testcase_18 AC 30 ms
27,408 KB
testcase_19 AC 28 ms
27,156 KB
testcase_20 AC 29 ms
25,008 KB
testcase_21 AC 29 ms
25,120 KB
testcase_22 AC 33 ms
25,132 KB
testcase_23 AC 28 ms
27,024 KB
testcase_24 AC 28 ms
25,204 KB
testcase_25 AC 28 ms
27,396 KB
testcase_26 AC 29 ms
27,272 KB
testcase_27 AC 29 ms
25,208 KB
testcase_28 AC 28 ms
25,080 KB
testcase_29 AC 28 ms
24,884 KB
testcase_30 AC 29 ms
27,136 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;

public class Program
{
    public static void Main() {
		int t = int.Parse(Console.ReadLine());
        int n = int.Parse(Console.ReadLine());
        int[] c = Console.ReadLine().Split(' ').Select(element => int.Parse(element)).ToArray();
        int[] v = Console.ReadLine().Split(' ').Select(element => int.Parse(element)).ToArray();		
		solve(t, c, v);
	}

    private static void solve(int t, int[] c, int[] v) {
		int[] dp = new int[t+1];
		
		for(int i=0;i<c.Length;i++)
        {
			int current = v[i];
		    while(current>0)
            {
				for(int j=dp.Length-1;j>=c[i];j--)
                {
					dp[j] = Math.Max(dp[j], dp[j-c[i]]+current);
				}
				current /= 2;
			}
		}		
		Console.WriteLine(dp[t]);
	}
}
0