Advertisement
Guest User

gatauah

a guest
Oct 10th, 2015
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main(){
  4. int people;
  5. scanf("%d", &people);fflush(stdin);
  6. int table;
  7. scanf("%d", &table);fflush(stdin);
  8. int a[100];
  9. int temp=0;
  10. a[-1]=0;
  11. for(int i=0;i<100;i++){
  12. a[i]=0;
  13. }
  14.  
  15. for(int i=0;i<table;i++){
  16. scanf("%d", &a[i]);fflush(stdin);
  17. }
  18.  
  19. for(int i=0;i<table;i++){
  20.  
  21. if(a[i]>=people){
  22. temp = temp+1;
  23.  
  24. }else if(a[i]+a[i-1]>=people){
  25. temp = temp+1;
  26.  
  27. }else if(a[i] + a[i+1]>=people){
  28. temp = temp+1;
  29.  
  30. }else if(a[i]+a[i-1]+a[i+1]>=people){
  31. temp = temp+1;
  32.  
  33. }
  34.  
  35. }
  36.  
  37. if(temp!=0){
  38. printf("YES");
  39. }else{
  40. printf("NO");
  41. }
  42.  
  43.  
  44. temp=0;
  45. getchar();
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement