Source Code
#include <bits/stdc++.h>
using namespace std;
#define   IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define   mp make_pair
#define   pb push_back
#define   ll long long
#define   ld long double
#define   debug(x)  cout << '[' << #x << " is: " << x << "] " << endl;
#define   rsor(v)   sort(v.rbegin() , v.rend());
#define   rev(v)    reverse(v.begin() , v.end());
#define   sz(x)     (int)(x).size()
#define   all(x)    x.begin(), x.end()
#define  _cout(v)  for(auto f : v ) cout << f << " " ;
#define  _cin(v)   for(auto &it : v)cin >> it ;
#define  _fo(v)  for(int i=0;i<(n);i++)
#define  vi vector<int>
#define  fs first
#define  sc second

int32_t main() {
    IOS;
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=0;i<n;i++){
        int mn=101;
        for(int j=0;j<n;j++){
            int x;
            cin>>x;
            if(x!=-1&&x<mn){
                mn=x;
            }
        }
        if(mn==1e5){
            cout<<"NO\n";
            return 0;
        }
        k-=mn;
        if(k<0){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES"<<'\n';
    return 0;

}
Copy
Omar's Gifts Anas_AbuAmar
GNU G++17
0 ms
556 KB
Wrong Answer