結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー nanophoto12nanophoto12
提出日時 2017-08-19 15:41:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,738 bytes
コンパイル時間 970 ms
コンパイル使用メモリ 91,940 KB
実行使用メモリ 6,016 KB
最終ジャッジ日時 2024-04-22 16:35:04
合計ジャッジ時間 1,780 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 6 ms
5,888 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 i = 0;i <= n;i++)
    {
        for(int y = 0;y <= gy;y++)
        {
            for(int x = 0;x <= gx;x++)
            {
                dp[i][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++)
        {
            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] + 1);
                }
                if(y > 0)
                {
                    dp[i+1][y][x] = min(dp[i+1][y][x], dp[i+1][y-1][x] + 1);
                }
            }
        }
    }
    cout << dp[n][gy][gx] << endl;
    return 0;
}
0