Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

不同算法思路,不知道哪里没考虑清楚,求帮助 #2

Open
MisakaMikoto07 opened this issue Aug 7, 2019 · 0 comments
Open

Comments

@MisakaMikoto07
Copy link

sist2019新生
我的思路是逐一比较每一段的起始位置a[i+1]和前一段的限制b[i]。如果a[i+1]<=b[i],那么就可以,反之只要出现一个就不行。这样写下的代码提交以后卡在test3。题中给的两组测试数据都是ok的,不知道问题出在哪里。
附c代码
`#include <stdio.h>
#include <stdbool.h>

int main(){
int n,m;
scanf("%d %d",&n,&m);
int a[n],b[n];
for(int i=0;i<n;i++){
scanf("%d %d",&a[i],&b[i]);
}
bool can=true;
for(int i=0;i<n-1;i++){
printf("%d:%d %d\n",i,a[i+1],b[i]);
if(a[i+1]>b[i]){
can=false;
}
}
printf("%d:%d %d\n",3,m,b[n-1]);
if(b[n-1]<m){
can=false;
}
if(can){
printf("YES");
}else{
printf("NO");
}
scanf("%d",&n);
return 0;
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant