結果

問題 No.37 遊園地のアトラクション
ユーザー sekiya9311sekiya9311
提出日時 2016-10-26 15:28:46
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 34 ms / 5,000 ms
コード長 1,580 bytes
コンパイル時間 2,100 ms
コンパイル使用メモリ 108,416 KB
実行使用メモリ 20,608 KB
最終ジャッジ日時 2024-04-18 19:53:31
合計ジャッジ時間 3,903 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
18,488 KB
testcase_01 AC 24 ms
18,944 KB
testcase_02 AC 26 ms
18,752 KB
testcase_03 AC 26 ms
18,816 KB
testcase_04 AC 26 ms
18,880 KB
testcase_05 AC 26 ms
18,884 KB
testcase_06 AC 24 ms
18,872 KB
testcase_07 AC 30 ms
20,096 KB
testcase_08 AC 24 ms
19,008 KB
testcase_09 AC 25 ms
18,816 KB
testcase_10 AC 28 ms
19,840 KB
testcase_11 AC 30 ms
19,584 KB
testcase_12 AC 28 ms
18,872 KB
testcase_13 AC 26 ms
18,744 KB
testcase_14 AC 24 ms
19,012 KB
testcase_15 AC 26 ms
18,748 KB
testcase_16 AC 26 ms
19,200 KB
testcase_17 AC 27 ms
19,072 KB
testcase_18 AC 33 ms
20,096 KB
testcase_19 AC 24 ms
18,816 KB
testcase_20 AC 26 ms
18,992 KB
testcase_21 AC 27 ms
18,616 KB
testcase_22 AC 34 ms
20,608 KB
testcase_23 AC 24 ms
19,072 KB
testcase_24 AC 25 ms
18,560 KB
testcase_25 AC 24 ms
18,944 KB
testcase_26 AC 22 ms
18,816 KB
testcase_27 AC 26 ms
18,876 KB
testcase_28 AC 23 ms
18,816 KB
testcase_29 AC 24 ms
18,864 KB
testcase_30 AC 23 ms
18,688 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.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Template
{
	static Scanner sc;
	public static void Main(string[] args)
	{
		sc = new Scanner();
		int T = sc.nextInt();
		int N = sc.nextInt();
		var c = sc.nextIntArray();
		var v = sc.nextIntArray();
		int[][] dp = new int[N + 1][];
		for (int i = 0; i <= N; i++)
		{
			dp[i] = Array.ConvertAll(new int[T * 2], e => e = -1);
		}
		dp[0][0] = 0;
		for (int i = 0; i < N; i++)
		{
			for (int j = 0; j < T + 1; j++)
			{
				int vbuf = v[i];
				int time = c[i];
				int vsum = 0;
				dp[i + 1][j] = Math.Max(dp[i][j], dp[i + 1][j]);
				while (vbuf > 0)
				{
					vsum += vbuf;
					if (j - time >= 0 && dp[i][j - time] != -1)
					{
						dp[i + 1][j] = Math.Max(dp[i + 1][j], dp[i][j - time] + vsum);
					}
					vbuf /= 2;
					time += c[i];
				}
			}
		}
		Console.WriteLine(dp[N].Max());
	}
}

public class Scanner
{
	public Scanner() { }
	public string next()
	{
		return Console.ReadLine();
	}
	public int nextInt()
	{
		return int.Parse(next());
	}
	public double nextDouble()
	{
		return double.Parse(next());
	}
	public long nextLong()
	{
		return long.Parse(next());
	}
	public string[] nextArray()
	{
		return next().Split(' ');
	}
	public int[] nextIntArray()
	{
		return Array.ConvertAll(nextArray(), e => int.Parse(e));
	}
	public long[] nextLongArray()
	{
		return Array.ConvertAll(nextArray(), e => long.Parse(e));
	}
	public double[] nextDoubleArray()
	{
		return Array.ConvertAll(nextArray(), e => double.Parse(e));
	}
}
0