求助,C++,#2下载数据后本地运行正确OA上还是WA
查看原帖
求助,C++,#2下载数据后本地运行正确OA上还是WA
1362323
jerry_K楼主2024/6/11 01:26

实在想不懂了,附上#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;
}
2024/6/11 01:26
加载中...