結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー grungrun
提出日時 2017-03-28 23:35:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 853 bytes
コンパイル時間 713 ms
コンパイル使用メモリ 75,664 KB
実行使用メモリ 4,564 KB
最終ジャッジ日時 2023-09-20 18:38:46
合計ジャッジ時間 1,809 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

struct crystal{
	int x;
	int y;
	int c;
	int safe;
};


using namespace std;

int Gx,Gy;
int N,F;

int main(){
	cin >> Gx >> Gy >> N >> F;
	vector<crystal> vec;
	int mx,my,mc,safe;
	for(int i = 0; 	i < N; i++){
		cin >> mx >> my >> mc;
		if((mx+my)*F > mc){
			safe = (mx+my)*F-mc;
			vec.push_back({mx,my,mc,safe});
		}//歩くよりもコストが少ない
	}
	sort(vec.begin(),vec.end(), [](crystal& a,crystal& b) {
		return (a.safe < b.safe);
	});
/*
	for(auto e: vec){
		 << e.x << "," << e.y << "," << e.c << "," << e.safe<<endl;
	}
*/
int x = 0, y = 0,cost = 0;
	for(int i = 0; i < vec.size(); i++){
		if(vec[i].x + x <= Gx && vec[i].y + y <= Gy){
			x += vec[i].x;
			y += vec[i].y;
			cost += vec[i].c;
		}
	}	
	cost += (Gx - x);
	cost += (Gy - y);
	cout << cost << endl;
	return 0;
}
0