CF 853D Michael and Charging Stations

原题走这里

基本想法,每22000元分一组

这样就可以花费2000积分,以20000的价格购买这些商品。

而对于最后一组,使用积分购买最后的2000元商品,其它全部全额购买

从而少花费了(最后一组总价/11)的钱


其中,要特判两种情况

一是总价不超过11000而最后一个商品是2000元时

二是所有商品价格全都是2000元时

大概就是这样,思维难度再一次与代码长度不成正比

#include
using namespace std;
int n,sum,tot,ans,a[400400];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
		sum+=a[i]/1000;
		tot+=(a[i]==1000);
	}
	int temp=sum*10/11;
	if(sum<=11) temp=sum-a[n]/1000;
	if(!tot && temp%2==1) temp--;
	cout<

其实还是没太搞懂

想死

你可能感兴趣的:(CF 853D Michael and Charging Stations)