結果

問題 No.669 対決!!! 飲み比べ
ユーザー ohreitetsuohreitetsu
提出日時 2018-05-20 11:21:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 749 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 73,428 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-10 23:56:01
合計ジャッジ時間 2,259 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <map>
using namespace std;
int main(int argc, char* argv[])
{
	int N,K;
	cin>>N>>K;
	multimap<int,int,greater<int>> myMap;
	int i;
	int A;
	for (i=0;i<N;i++){
		cin>>A;
		if (A>0){
			myMap.insert(multimap<int,int,greater<int>>::value_type(A,0));
		}
	}
	int Ju=0;
	int Den=0;
	bool JuDrink=true;
	multimap<int,int,greater<int>>::iterator mit;
	while (myMap.size()>0){
		mit=myMap.begin();
		int x=(*mit).first;
		if (x==0){
			break;
		}
		int y=x>=K?K:x;
		if (JuDrink){
			Ju+=y;
			JuDrink=false;
		}else{
			Den+=y;
			JuDrink=true;
		}
		x-=y;
		myMap.erase(mit);
		if (x>0){
			myMap.insert(multimap<int,int>::value_type(x,0));
		}
	}
	if (Ju>Den){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}
0