結果
| 問題 |
No.496 ワープクリスタル (給料日前編)
|
| コンテスト | |
| ユーザー |
nanophoto12
|
| 提出日時 | 2017-08-19 15:47:44 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 1,835 bytes |
| コンパイル時間 | 737 ms |
| コンパイル使用メモリ | 92,388 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2024-10-14 15:46:46 |
| 合計ジャッジ時間 | 1,547 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
ソースコード
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> t3;
using namespace std;
#define MAX_N 110
int dp[MAX_N][MAX_N][MAX_N];
int main(){
int gx,gy,n,f;
cin >> gx >> gy >> n >> f;
for(int y = 0;y <= gy;y++)
{
for(int x = 0;x <= gx;x++)
{
dp[0][y][x] = (x + y) * f;
}
}
for(int i = 0;i < n;i++)
{
int sx,sy,sc;
cin >> sx >> sy >> sc;
for(int y = 0;y <= gy;y++)
{
for(int x = 0;x <= gx;x++)
{
dp[i+1][y][x] = dp[i][y][x];
}
}
for(int y = 0;y <= gy;y++)
{
ll ny = sy + y;
if(ny > gy)
{
continue;
}
for(int x = 0;x <= gx;x++)
{
ll nx = sx + x;
if(nx > gx)
{
continue;
}
dp[i+1][ny][nx] = min(dp[i+1][ny][nx], dp[i][y][x] + sc);
}
}
for(int y = 0;y <= gy;y++)
{
for(int x = 0;x <= gx;x++)
{
if(x > 0)
{
dp[i+1][y][x] = min(dp[i+1][y][x], dp[i+1][y][x-1] + f);
}
if(y > 0)
{
dp[i+1][y][x] = min(dp[i+1][y][x], dp[i+1][y-1][x] + f);
}
}
}
}
cout << dp[n][gy][gx] << endl;
return 0;
}
nanophoto12