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=1;i<=n;i++){
        min = 9999;
        for(int j=1;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 sharawi
GNU G++17
52 ms
580 KB
Wrong Answer