Source Code
#include <iostream>
using namespace std;
long long n,m,k,t;
int sum;
int count;
int main()
{
    int min = 9999;
    cin>>n>>m>>k;
    int arr[500];
    for(int i=0;i<n;i++){
        min = 9999;
        count= 0;
        for(int j=0;j<m;j++){
            cin>>arr[j];
            if(arr[j] < min && arr[j] != -1 ){
                min = arr[j];

            }
            if(arr[j] == -1){
                count++;
            }
            if(count >= m){
                cout<<"NO"<<endl;
                return 0;
            }

        }
        sum+=min;

    }
    if(sum <= k){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }







    return 0;
}
Copy
Omar's Gifts Rimawi
GNU G++17
32 ms
948 KB
Accepted