Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main(){
- int people;
- scanf("%d", &people);fflush(stdin);
- int table;
- scanf("%d", &table);fflush(stdin);
- int a[100];
- int temp=0;
- a[-1]=0;
- for(int i=0;i<100;i++){
- a[i]=0;
- }
- for(int i=0;i<table;i++){
- scanf("%d", &a[i]);fflush(stdin);
- }
- for(int i=0;i<table;i++){
- if(a[i]>=people){
- temp = temp+1;
- }else if(a[i]+a[i-1]>=people){
- temp = temp+1;
- }else if(a[i] + a[i+1]>=people){
- temp = temp+1;
- }else if(a[i]+a[i-1]+a[i+1]>=people){
- temp = temp+1;
- }
- }
- if(temp!=0){
- printf("YES");
- }else{
- printf("NO");
- }
- temp=0;
- getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement