Source Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void lets_hope_its_right(){
    int n,m,k; cin>>n>>m>>k;
    bool done=1;
    int ans=0;
    for(int i=0;i<n;i++){
        int cur=INT_MAX;
        for(int j=0;j<m;j++){
            int x; cin>>x;
            if(x!=-1) cur=min(cur,x);
        }
        if(cur!=INT_MAX) ans+=cur;
        else done=0;
    }
    if(done&&ans<=k) cout<<"YES";
    else cout<<"NO";
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt=1; //cin>>tt;
    while(tt--) lets_hope_its_right();
}
Copy
Omar's Gifts YazanIstatiyeh
GNU G++17
12 ms
948 KB
Accepted