結果
| 問題 |
No.496 ワープクリスタル (給料日前編)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-24 23:14:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,053 bytes |
| コンパイル時間 | 868 ms |
| コンパイル使用メモリ | 65,500 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-07-05 23:56:34 |
| 合計ジャッジ時間 | 4,250 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 4 TLE * 1 -- * 18 |
ソースコード
#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;
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;
}