結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー tsubametsubame
提出日時 2017-03-24 23:23:46
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,058 bytes
コンパイル時間 1,159 ms
コンパイル使用メモリ 66,272 KB
実行使用メモリ 7,772 KB
最終ジャッジ日時 2023-09-20 03:51:47
合計ジャッジ時間 5,202 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<utility>

using namespace std;

int calc_score(vector< vector<int> > c, int i, int x, int y, int max_x, int max_y, int score, int F) {
    if (i == c.size()){
        return F * (max_x + max_y - x - y) + score;
    }
    else if (c[i][0] + x > max_x || c[i][1] + y > max_y) {
        return calc_score(c, i+1, x, y, max_x, max_y, score, F);
    }
    else {
        return min(calc_score(c, i+1, x, y, max_x, max_y, score, F), calc_score(c, i+1, x+c[i][0], y+c[i][1], max_x, max_y, score+c[i][2], F));
    }
}


int main(){
    int X, Y, N, F, score;
    vector<vector<int> > crystal;

    cin >> X >> Y >> N >> F;
    
    //for (int i = 0; i < N; ++i) {
        int x, y, c;
    while(cin >> x >> y >> c){
        if (F * (x + y) <= c) {
            continue;
        }
        vector<int> tmp;
        tmp.push_back(x);
        tmp.push_back(y);
        tmp.push_back(c);
        crystal.push_back(tmp);
    }

    score = calc_score(crystal, 0, 0, 0, X, Y, 0, F);

    cout << score << endl;

    return 0;
}
0