题意:给你n扇门和每扇门的生命值,同时已知你对门的伤害值x和神的治疗值y(给门提升y生命值),一扇门在生命值降为0或0以下就没得救了。问在你和神都做出最有选择的情况下你最多能破坏几扇门?
题解:当x>y时,所有门都能被破坏。当x<=y时,先统计门的原始生命值比x小的数量cnt,你会优先去破坏这些门,同时神也会救这些门,所以最多能破坏(cnt+1)/2扇门。
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
int n,x,y;
int a[550];
int cnt=0;
cin>>n>>x>>y;
for(int i=0;i<n;i++)
{
cin>>a[i];
if(a[i]<=x)
cnt++;
}
if(x>y)
cout<<n<<endl;
else
cout<<(cnt+1)/2<<endl;
return 0;
}