結果
| 問題 |
No.496 ワープクリスタル (給料日前編)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-09-14 00:00:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 983 bytes |
| コンパイル時間 | 1,654 ms |
| コンパイル使用メモリ | 168,868 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-01 04:34:07 |
| 合計ジャッジ時間 | 2,456 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define int long long
const int inf = 100100100100100;
const int mod = 1000000007;
signed main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int x,y, n, f;
cin >> x >> y >> n >> f;
int dp[y+1][x+1];
dp[0][0] = 0;
rep(i,1,y+1){
dp[i][0] = dp[i-1][0] + f;
}
rep(i,0,y+1){
rep(j,1,x+1){
dp[i][j] = dp[i][j-1] + f;
}
}
int crystals[n][3];
rep(i,0,n){
rep(j,0,3){
cin >> crystals[i][j];
}
}
rep(k,0,n){
for(int i = y; i > -1; i--){
for(int j = x; j > -1; j--){
int dx = j-crystals[k][0];
int dy = i-crystals[k][1];
if(-1 < dx && -1 < dy){
dp[i][j] = min(dp[i][j], dp[dy][dx] + crystals[k][2]);
}
}
}
}
cout << dp[y][x] << endl;
}