結果

問題 No.37 遊園地のアトラクション
ユーザー Yang33Yang33
提出日時 2018-04-11 00:07:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 2,782 bytes
コンパイル時間 1,468 ms
コンパイル使用メモリ 167,180 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 20:05:54
合計ジャッジ時間 2,329 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 4 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/04/10  Problem: yukicoder 037  / Link: http://yukicoder.me/problems/no/037  ----- */
/* ------問題------

Raymondは、遊園地に遊びに来ている。
遊園地の滞在時間はT時間で、各アトラクションの満足度が i番目のアトラクションに乗ったら、満足度Viが得られる。

しかし、遊園地は、どのアトラクションも行列であり、なかなか乗ることが出来ない。
i番目のアトラクションの行列は、ci時間並ぶことでアトラクションに乗れるとする。
(アトラクション自体の時間は行列の時間に含まれているとする)

しかし、Raymondは同じアトラクションにはあまり乗りたくない。
滞在時間中に同じアトラクションに乗った場合は、 満足度は「Viの半分小数切り捨て」しか得られず、その値を新たなViとする。
それ以降、また同じアトラクションに乗るたびに半減していく。

滞在時間の T時間の間に得られる最大の満足度を得たいとするとき、 その得られる満足度を求めてください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	LL T, N;	cin >> T >> N;
	VI c(N), v(N);
	FOR(i, 0, N) {
		cin >> c[i];
	}
	FOR(i, 0, N) {
		cin >> v[i];
	}
	VI dp(T + 1, -INF);
	dp[0] = 0;
	FOR(i, 0, N) {
		FORR(t, T - 1, 0 - 1) {
			int sumT = 0;
			int sumV = 0;
			int V = v[i];
			FOR(j, 0, 10) {
				sumT += c[i];
				sumV += V;
				V /= 2;
				if (t + sumT <= T && dp[t] >= 0 && sumV > 0) {
					dp[t + sumT] = max(dp[t + sumT], dp[t] + sumV);
				}

			}
		}
	}
	int ans = 0;
	FOR(t, 0, T + 1) {
		ans = max(ans, dp[t]);
	}
	cout << ans << "\n";

	return 0;
}
0