結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー |
![]() |
提出日時 | 2017-03-24 23:46:18 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 1,217 bytes |
コンパイル時間 | 1,678 ms |
コンパイル使用メモリ | 158,684 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-06 01:42:35 |
合計ジャッジ時間 | 1,857 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h>#define rep(x, to) for (int x = 0; x < (to); x++)#define REP(x, a, to) for (int x = (a); x < (to); x++)#define EPS (1e-14)#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}using namespace std;typedef long long ll;typedef pair<int, int> PII;typedef pair<ll, ll> PLL;typedef complex<double> Complex;typedef vector< vector<int> > Mat;const int INF = 1e+9 + 7;int Gx, Gy;int N, F;int x[55], y[55], c[55];int dp[55][105][105];void solve() {for (int i = 0; i < 105; i++) {for (int j = 0; j < 105; j++) {dp[0][i][j] = F * i + F * j;}}for (int i = 0; i < N; i++) {for (int j = 0; j < 105; j++) { // yfor (int k = 0; k < 105; k++) { // xdp[i+1][j][k] = dp[i][j][k];if (j-y[i] >= 0 && k-x[i] >= 0) {dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j-y[i]][k-x[i]] + c[i]);}}}}cout << dp[N][Gy][Gx] << endl;#if 0rep(i, 5) {rep(j, 5) {rep(k, 5) {cout << dp[i][j][k] << " ";}cout << endl;}cout << endl;}#endif}int main() {cin >> Gx >> Gy >> N >> F;rep(i, N) {cin >> x[i] >> y[i] >> c[i];}solve();return 0;}