結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー face4
提出日時 2018-09-22 19:44:46
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 685 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 66,668 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-18 11:41:04
合計ジャッジ時間 1,436 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

int main(){
    int gx, gy, n, f, x, y, c;
    cin >> gx >> gy >> n >> f;

    int dist[101][101] = {};
    for(int i = 1; i <= 100; i++)   dist[0][i] = dist[0][i-1] + f;
    for(int i = 1; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            dist[i][j] = dist[i-1][j] + f;
        }
    }

    for(int q = 0; q < n; q++){
        cin >> x >> y >> c;
        if((x+y) * f < c)   continue;
        for(int i = 100-x; i >= 0; i--){
            for(int j = 100-y; j >= 0; j--){
                dist[i+x][j+y] = min(dist[i+x][j+y], dist[i][j] + c);
            }
        }
    }

    cout << dist[gx][gy] << endl;
    
    return 0;
}
0