結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー kotatsugamekotatsugame
提出日時 2021-11-12 21:26:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 260 ms / 3,000 ms
コード長 513 bytes
コンパイル時間 926 ms
コンパイル使用メモリ 69,560 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-16 21:28:01
合計ジャッジ時間 7,377 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 233 ms
4,380 KB
testcase_05 AC 250 ms
4,380 KB
testcase_06 AC 87 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 129 ms
4,380 KB
testcase_09 AC 176 ms
4,380 KB
testcase_10 AC 79 ms
4,376 KB
testcase_11 AC 68 ms
4,376 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 151 ms
4,380 KB
testcase_14 AC 176 ms
4,380 KB
testcase_15 AC 230 ms
4,380 KB
testcase_16 AC 71 ms
4,376 KB
testcase_17 AC 116 ms
4,380 KB
testcase_18 AC 97 ms
4,380 KB
testcase_19 AC 59 ms
4,380 KB
testcase_20 AC 49 ms
4,380 KB
testcase_21 AC 147 ms
4,380 KB
testcase_22 AC 211 ms
4,380 KB
testcase_23 AC 243 ms
4,384 KB
testcase_24 AC 260 ms
4,376 KB
testcase_25 AC 217 ms
4,380 KB
testcase_26 AC 247 ms
4,380 KB
testcase_27 AC 234 ms
4,380 KB
testcase_28 AC 251 ms
4,376 KB
testcase_29 AC 240 ms
4,380 KB
testcase_30 AC 241 ms
4,384 KB
testcase_31 AC 252 ms
4,376 KB
testcase_32 AC 244 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:22:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   22 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N,A,B,X,Y;
int Hi[1<<17];
int H[1<<17];
bool check(int K)
{
	int a=A;
	long all=(long)Y*B;
	for(int i=0;i<N;i++)
	{
		H[i]=Hi[i]-K;
		if(H[i]<0)H[i]=0;
		while(a>0&&H[i]>=X)H[i]-=X,a--;
		all-=H[i];
	}
	sort(H,H+N);
	for(int i=0;i<a&&i<N;i++)all+=H[N-i-1];
	return all>=0;
}
main()
{
	cin>>N>>A>>B>>X>>Y;
	for(int i=0;i<N;i++)cin>>Hi[i];
	int L=-1,R=1e9;
	while(R-L>1)
	{
		int mid=(L+R)/2;
		if(check(mid))R=mid;
		else L=mid;
	}
	cout<<R<<endl;
}
0