結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー u-shou-sho
提出日時 2017-08-23 15:41:54
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,256 bytes
コンパイル時間 853 ms
コンパイル使用メモリ 60,504 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 13:09:18
合計ジャッジ時間 1,409 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 1 ms
5,376 KB
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 <iostream>
#include <algorithm>
using namespace std;

struct crystal{int x,y,c, otoku;};

bool cospa( const crystal &cry1, const crystal &cry2 ){
    if(cry1.otoku != cry2.otoku) return cry1.otoku < cry2.otoku;
    else return cry1.x+cry1.y < cry2.x+cry2.y;
}

int main(){
    int Gx, Gy, N, F;
    cin >> Gx >> Gy >> N >> F;

    crystal crystals[N];
    for(int i=0; i<N; i++){
        cin >> crystals[i].x >> crystals[i].y >> crystals[i].c;
        if(crystals[i].x>0 && crystals[i].y>0){
            crystals[i].otoku = crystals[i].c - F*(crystals[i].x + crystals[i].y);
        }else{
            crystals[i].otoku = 0;
        }
    }
    sort(crystals, crystals+N, cospa);

    //moveCost[i][j]=(i,j)に行くのにかかる最小料金
    int moveCost[Gx+1][Gy+1];
    for(int i=0; i<=Gx; i++){
        for(int j=0; j<=Gy; j++){
            moveCost[i][j] = (i+j)*F; //全部歩いたときのコスト
        }
    }

    for(int k=0; crystals[k].otoku<0; k++){
        for(int i=Gx; i>=crystals[k].x; i--){
            for(int j=Gy; j>=crystals[k].y; j--){
                moveCost[i][j] = moveCost[i-crystals[k].x][j-crystals[k].y] + crystals[k].c;
            }
        }
    }

    cout << moveCost[Gx][Gy] << endl;

    return 0;
}
0