結果
| 問題 | No.496 ワープクリスタル (給料日前編) |
| コンテスト | |
| ユーザー |
zenito9970
|
| 提出日時 | 2017-03-24 23:02:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,445 bytes |
| 記録 | |
| コンパイル時間 | 1,700 ms |
| コンパイル使用メモリ | 173,704 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-05 23:09:51 |
| 合計ジャッジ時間 | 2,605 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 8 WA * 15 |
ソースコード
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
const int dx[] = {0, 1};
const int dy[] = {1, 0};
struct Crystal {
int x, y, c;
Crystal() = default;
Crystal(int x, int y, int c): x(x), y(y), c(c) {}
};
bool operator > (const Crystal& a, const Crystal& b) {
return ((a.x + a.y) / a.c) > ((b.x + b.y) / b.c);
}
int main() {
int gx, gy, n, f; cin >> gx >> gy >> n >> f;
vector<Crystal> crs;
rep(i, n) {
int x, y, c; cin >> x >> y >> c;
if((x + y) * f <= c) continue;
crs.push_back(Crystal(x, y, c));
}
int x = 0, y = 0, cost = 0;
sort(all(crs), greater<Crystal>());
const int cn = crs.size();
rep(i, cn) {
if(x + crs[i].x <= gx && y + crs[i].y <= gy) {
x += crs[i].x;
y += crs[i].y;
cost += crs[i].c;
}
}
cost += (gx - x + gy - y) * f;
cout << cost << endl;
return 0;
}
zenito9970