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

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

	cout << "YES";

}
Copy
Omar's Gifts Anas_AbuAmar
GNU G++17
11 ms
936 KB
Accepted