#include <stdio.h> typedef struct node { int l,r; }node; int main(){ int t; scanf("%d",&t); while(t--){ int i,maxlen=0,n; scanf("%d",&n); node hook[50000]; for(i=0; i < n; i++){ scanf("%d%d",&hook[i].l,hook[i].r); if(maxlen < hook[i].r-hook[i].l) maxlen = hook[i].r-hook[i].l; } int sum=hook[0].l; int flag=1; for(i=0; i < n-1; i++) sum +=maxlen; if(sum > hook[i+1].l){ flag=0; break; } } if(flag== 1) printf("YES"); else printf("NO"); } return 0; } /* Main.c: In function 'main': Main.c:15:11: warning: format '%d' expects argument of type 'int *', but argument 3 has type 'int' [-Wformat=] scanf("%d%d",&hook[i].l,hook[i].r); ^ Main.c:20:13: warning: variable 'flag' set but not used [-Wunused-but-set-variable] int flag=1; ^ Main.c:28:12: error: 'flag' undeclared (first use in this function) if(flag== 1) ^ Main.c:28:12: note: each undeclared identifier is reported only once for each function it appears in Main.c: At top level: Main.c:33:7: error: expected identifier or '(' before 'return' return 0; ^ Main.c:34:5: error: expected identifier or '(' before '}' token } ^ */ |
Double click to view unformatted code.