結果
| 問題 |
No.496 ワープクリスタル (給料日前編)
|
| コンテスト | |
| ユーザー |
nenuon
|
| 提出日時 | 2017-06-23 18:58:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 841 bytes |
| コンパイル時間 | 758 ms |
| コンパイル使用メモリ | 89,964 KB |
| 実行使用メモリ | 5,632 KB |
| 最終ジャッジ日時 | 2024-10-04 00:51:00 |
| 合計ジャッジ時間 | 1,647 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
ソースコード
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
int main(){
int gy,gx,n,f;
cin>>gx>>gy>>n>>f;
int x[n],y[n],c[n];
FOR(i,0,n){
cin >> x[i] >> y[i] >> c[i];
}
int dp[n+1][gy+1][gx+1];
FOR(j,0,gy+1){
FOR(k,0,gx+1){
dp[0][j][k] = (j + k) * f;
}
}
FOR(i,1,n+1){
FOR(j,0,gy+1){
FOR(k,0,gx+1){
dp[i][j][k] = dp[i-1][j][k];
if(j >= y[i-1] && k >= x[i-1]){
dp[i][j][k] = min(dp[i-1][j-y[i-1]][k-x[i-1]]+c[i-1], dp[i-1][j][k]);
}
}
}
}
cout << dp[n][gy][gx] << endl;
return 0;
}
nenuon