竞赛讨论区 > 最后一步!!!
头像
Southside
发布于 02-13 12:56
+ 关注

最后一步!!!

求求大佬指导,自测运行过了,但提交通过不了,没看出问题

G

why买外卖

#include <iostream>using namespace std;int main(){int T;cin>>T;

for(int i=0;i<T;i++){
	int x=0;
	int n,m;
	cin>>n>>m;
	int c[n],d[n];
	int max=0;
	int sum=m;;
	for(int j=0;j<n;j++){
		cin>>c[j]>>d[j];
		if(j==0) max=c[0];
		else{
			if(c[j]>max) max=c[j];
		}
		sum=sum+d[j];
	}
	if(max<=sum){
		x=sum;
	}
	else{
		for(int j=0;j<n;j++){
		if(d[j]+m>=c[j]) x=d[j]+m;
		else if(d[j]+m<c[j]&&j==0) x=x+m;
		else{x=x;
		} 
	}
}
	cout<<x<<endl;
}
return 0;

}

全部评论

(0) 回帖
加载中...
话题 回帖

等你来战

查看全部

热门推荐