結果
| 問題 |
No.496 ワープクリスタル (給料日前編)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-29 11:36:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 984 bytes |
| コンパイル時間 | 519 ms |
| コンパイル使用メモリ | 65,900 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-06 15:03:01 |
| 合計ジャッジ時間 | 1,656 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 RE * 1 |
| other | AC * 4 WA * 18 RE * 1 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct crystal{
int x;
int y;
int c;
int safe;
};
bool comp(const crystal &a, const crystal &b){
if(a.safe < b.safe) return true;
return false;
}
int main(){
int gx,gy,N,F;
cin >> gx >> gy >> N >> F;
vector<crystal> cry;
int x,y,c,safe=0;
for(int i = 0; i < N;i++){
cin >> x >> y >> c;
safe = (x+y)*F - c;
if(safe > 0){
cry.push_back({x,y,c,safe});
}
}
sort(cry.begin(),cry.end(),comp);
/*
for(auto e : cry){
cout << e.x << "," << e.y << "," << e.c << "," << e.safe << endl;
}*/
int tcost = 0,px=0,py=0;
for(int i = 0; i < N; i++){
if(px + cry[i].x <= gx && py + cry[i].y <= gy){
px += cry[i].x;
py += cry[i].y;
tcost += cry[i].c;
}
}
tcost += (gx-py)*F;
tcost += (gy-py)*F;
cout << tcost << endl;
return 0;
}