Source Code

#include<stdio.h>

int main(){
        int n,m,k;
        scanf("%d%d",&n,&m);
        int om[n][m];
        int a=0;
        int total=0;
        int min=501;
        for (int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                        scanf("%d",&om[i][j]);
                }
        }
        int flag=0;
        for (int i=0;i<n;i++){
                min=501;
                for(int j=0;j<m;j++){
                        
                        if (om[i][j]==-1)
                        flag=1;
                        else 
                        flag=0;
                


                      if (om[i][j]<=k  && flag==0){
                              a=om[i][j];
                             if (a<min ) min=a;

                      }
                      total=total+a;


                }
              
        }
  if (total<=k)
                printf("YES");
                else
                printf("NO");

}
Copy
Omar's Gifts Reem-Assi
GNU GCC C11
2 ms
428 KB
Wrong Answer