WA……
查看原帖
WA……
513807
O3O_O3O_O3O楼主2021/7/4 17:59

我分别输入了两个样例组的样例输入,输出的也没有什么毛病,为什么到提交的时候就全都WA了呢?

我的代码:

#include<iostream> 
#include<cstdio>
using namespace std; 
int main(){
	int n,a[10001]={},b[10001]={},c=0,d=1;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	b[1]=a[1];
	b[1] = a[1];
	for(int x=2;x<=n;x++){
		c = a[d];
		for(int y=d;y<=x;y++){
			if((a[y]>=c)&&(a[y]<=a[x])) {
				c=a[y];
				b[x]+=a[y];
			}
			else{
				if(y==d){
					d++;
					x-=1;
				}
			}
		}
	}
	for(int z=1;z<=n;z++){
		cout << b[z];
		if(z!=n){
			cout << " ";
		}
	}
	return 0;
} 
2021/7/4 17:59
加载中...