实在想不懂了,附上#2 WA且只得40分的代码
两个示例得到的数对,但是不知道是不是没有超出预算的输出格式有问题,求大佬指点!
#include <iostream>
#include <algorithm>
#include<cmath>
using namespace std;
int main() {
int budget[12],money[12],left[12];
int mum = 0;
int count =0;
for(int i=0;i<12;i++){
cin>>budget[i];
money[i]=0;
left[i]=0;
}
money[0] = 300;
int j = 0;
for(j=0;j<12;j++)
{
if(money[j]<budget[j])
{
break;
}
left[j] = money[j] - budget[j];
if(left[j]>=100)
{
int x = left[j]/100;
mum = mum + x*100;
left[j] = left[j]%100;
}
money[j+1] = left[j] + 300;
count++;
}
if(count<12){
cout<<'-'<<count+1<<endl;
}else{
cout<<int(mum*1.2+left[11])<<endl;
}
return 0;
}