結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー |
|
提出日時 | 2017-03-24 23:23:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,058 bytes |
コンパイル時間 | 690 ms |
コンパイル使用メモリ | 67,144 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-07-06 00:08:37 |
合計ジャッジ時間 | 4,361 ms |
ジャッジサーバーID (参考情報) |
judge1 / 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;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;}