結果
| 問題 |
No.1739 Princess vs. Dragoness (& AoE)
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2021-11-12 22:30:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 470 ms / 3,000 ms |
| コード長 | 891 bytes |
| コンパイル時間 | 2,118 ms |
| コンパイル使用メモリ | 198,280 KB |
| 最終ジャッジ日時 | 2025-01-25 17:05:57 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
ll n,aa,b,x,y;
ll A[100100];
bool f(ll k){
ll a=aa;
vector<ll> H(n);
rep(i,n) H[i]=A[i]-k;
sort(ALL(H));
reverse(ALL(H));
int now=0;
while(a>0 && now<n && H[now]>=x){
H[now]-=x;
a--;
if(H[now]<x) now++;
}
sort(ALL(H));
reverse(ALL(H));
now=0;
while(a>0 && now<n){
H[now]-=x;
a--;
now++;
}
if(now==n){
return true;
}
ll sum=0;
rep(i,n){
if(H[i]>0) sum+=H[i];
}
if(sum<=b*y) return true;
else return false;
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
cin>>n>>aa>>b>>x>>y;
rep(i,n) cin>>A[i];
ll ng=-1,ok=1e9+7;
while(ok-ng>1){
ll mid=(ok+ng)/2;
if(f(mid)) ok=mid;
else ng=mid;
}
cout<<ok<<endl;
return 0;
}
umezo