結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー | hanorver |
提出日時 | 2017-03-31 15:03:44 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 4,232 bytes |
コンパイル時間 | 663 ms |
コンパイル使用メモリ | 83,476 KB |
実行使用メモリ | 11,368 KB |
最終ジャッジ日時 | 2024-07-07 04:41:41 |
合計ジャッジ時間 | 2,665 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
11,164 KB |
testcase_01 | AC | 3 ms
11,252 KB |
testcase_02 | AC | 3 ms
11,220 KB |
testcase_03 | AC | 2 ms
11,276 KB |
testcase_04 | AC | 3 ms
11,308 KB |
testcase_05 | AC | 3 ms
11,356 KB |
testcase_06 | RE | - |
testcase_07 | AC | 4 ms
11,256 KB |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | AC | 4 ms
11,228 KB |
testcase_11 | AC | 3 ms
11,224 KB |
testcase_12 | AC | 3 ms
11,272 KB |
testcase_13 | AC | 3 ms
11,216 KB |
testcase_14 | AC | 4 ms
11,368 KB |
testcase_15 | AC | 3 ms
11,128 KB |
testcase_16 | AC | 3 ms
11,216 KB |
testcase_17 | AC | 4 ms
11,176 KB |
testcase_18 | AC | 4 ms
11,140 KB |
testcase_19 | RE | - |
testcase_20 | AC | 4 ms
11,140 KB |
testcase_21 | AC | 3 ms
11,236 KB |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cmath> #include <map> /* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::'''```````::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::''`_,-''.,... `:::::::::::::::::: :::::::::::::::::::::::::::::::::::::' _,-',;;!!!!!!!!!; `:::::::::::::::: ::::::::::::::'`````:::::::::::::'' .-' ;<!!!!!!!'''`_..' `::::::::::::::: ::::::::::'' ,;!!!;,`::::::::::' .-`.,,,zcccc,,cccd$$"",;> `:::::::::::::: :::::::::' ;!!!!!!!!; ``:::::' ;' ,c$$$$$$$$$$$CC<<" ````_ :::::::::::::: :::::::' ;!!!!!!!!!!!!!; ' ;! z$$$$$$$$$$$$$$$$$$$$$$??". :::::::::::::: ::::::: <!!!!!!!!!!!!!' . .!',c$$$$$$$$$$$$$c, `"""',;;<!! :::::::::::::: :::::: ,!!!!!!!!!!!'`,;! .<! ,$$$$$$$$$$$$$$$$hc,,,..- !!!! `::::::::::::: ::::' <!!!!!!!!!' .<!!!;!! ,$$$$$""???$$$"""?????"" .<!!!! :::::::::::::: ::: ;><!!!!!!!!! ,<!!!!!!!',c, "??.< . "??h. -;;;;!!!!!!!' :::::::::::::: ::: !!!!!!!!!!' ;!!!!!!!!' d$$h.`$ccr,$h `;,." `!!!!!!!!! ::::::::::::::: :::.`<!!!!!!!' !!!!!!!!!! dP"""?.`$$F`$$h.`!!!!!!!!!!!!!! .::::::::::::::: ::::. <!!!!!! !!!!!!!!!! ,$ .nn.' "$$ P" <!!!!!!!!!!!' .:::::::::::::::: :::::. <!!!! ;!!!!!!!!!! $$ MMMMx ?$ ,dx `!!!!!!!!!!' :::::::::::::::::: ```:::: `!!! !!!'!!!!!! `$ MMMMMM, $r MMMr !!!!!!!!' .::::::::::::::::::: `!!;,.`' ``' ``,;!!!!' ch." 4MMMMMM "$ 4MMM `!!!!!' ..:::::::::::::::::::: !!!!!'````'``<!!!'`.z$$$$. MMMMMMb $h MMM `!!'' .::::::::::::::::::::::: ..``.,d$$$$$c,,,. $$$$$F"? "MMMMMM $$ 4P" ' .:::::::::::::::::::::::::: dM""..""?$$$$$$$$$$$$$$$$$$c "MM" $$>` ,c `::::::::::::::::::::::::: MMn.`"?hc,d$$$$$$$$$$$$$$$$$$. `P $P' -??P== `::::::::::::::::::::::: MMMMMnx`"?$$$$$$$$$$$P".,.`"??$ccccc$.z$$$$. `' .:::::::::::::::::' '' MMMMMM,' .?$$$$$$$$$$ d$$$ d$$$$$$$$$$$$$h..``::::::::::::::::' MMMMMMMn `?$$$$$$$$$$,.?$$h. =."?$$$$$$$$$$$$$$hc,.``'::::::::::' MMMMMMMM ;, `"??$$$$$$h ?$$h. -m,``""??$$$$$$$$$$$$$c,.``````' MMMMMMM> !!! ?cc,.,d$$$$h.`"?$hc `P .`"?$$$$$$$$$$$$$$$$$$$ .: MMMMMMM ,!!'. $$$$$$$$$??=== `"""=c, " P n. "$$$$$$$$$$$$$$$$c_ ,.:::: MMMMMMP !!! Mr<$$$$"".,c,;M ;<!! ..""=_ ' 4 .br .`""??$$$$$$$$??"".::::::: MMMMMM';!!',M>'$$$$$$$$$>4M `!!! 4MMbn.`"=cc," -'P",c=.,.`.. .= ::::::::: MMMMM' !!! dMb $$$$$$$$P MM> !!! 4MMMMMMr :..`"-._""Pr4"'-P" .,.`::::::::: MMMM' <!!!,MMM "$$$$$$P dMM>;!!! 4MMMMMMb :::::.. "-=cczyycc??" .::::::::: MMMP <!!! dMMMb "?$$P" uMMM>;!!! 4MMMMMMMr`:::::::::.........::::::::::::: MMP';!!! ;MMMMMMn,.".uMMMMM ;!!! MMMMMMMMM,`:::::::::::::::::::::::::::::: MM ;!!!! MMMMMMMMMMMMMMMMMM !!!! MMMMMMMMMb `::::::::::::::::::::::::::::: M" !!!! uMMMMMMMMMMMMMMMMMP !!! ;MMMMMMMMMMx ::::::::::::::::::::::::::::: P.!!!! ,MMMMMMMMMMMMMMMMMM ,!!! MMMMMMMMMMMMx`:::::::::::::::::::::::::::: !!!!> MMMMMMMMMMMMMMMMMMP !!!',MMMMMMMMMMMMM `::::::::::::::::::::::::::: */ int main() { int gx, gy, crystals, fee; std::cin >> gx >> gy >> crystals >> fee; std::vector<std::pair<std::pair<int, int>, int> > v(crystals); for (int i = 0; i < crystals; i++) { int x, y, f; std::cin >> x >> y >> f; v[i] = { {x, y}, f }; }; long long dp[100][100][100]; for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { for (int k = 0; k < 100; k++) { dp[i][j][k] = 10000000000; } } } for (int i = 0; i < 100; i++) { dp[0][0][i] = 0; } for (int i = 0; i <= gy; i++) { for (int j = 0; j <= gx; j++) { dp[i + 1][j][0] = std::min(dp[i + 1][j][0], dp[i][j][0] + fee); dp[i][j + 1][0] = std::min(dp[i][j + 1][0], dp[i][j][0] + fee); for (int k = 0; k < crystals; k++) { dp[i][j][k + 1] = std::min(dp[i][j][k + 1], dp[i][j][k]); if (v[k].first.first + j <= gx && v[k].first.second + i <= gy) { dp[i + v[k].first.second][j + v[k].first.first][k + 1] = std::min(dp[i + v[k].first.second][j + v[k].first.first][k + 1], dp[i][j][k] + v[k].second); } } } } long long ans = dp[gy][gx][0]; for (int i = 0; i < crystals; i++) { ans = std::min(ans, dp[gy][gx][i + 1]); } std::cout << ans << std::endl; return 0; }