Source Code
//============================================================================
// Name        : mmmmmmmm.cpp
// Author      : sameh mohamed
// Copyright   : don't try i'm warnning you......
// Description : Hello World
//============================================================================
//Egypt came then History
//Pharoas were coders but using different compilers{}{}{}{}{}}}}{{{{@#$%^^&&$$$###()()(***)))([][][][][]]][
#include<bits/stdc++.h>
#include <iostream>
#include<string>
#include<algorithm>
#include<set>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int main()
{
int n,m,k;
cin>>n>>m>>k;
vector<long>a;
long long s=0;
for(int i=0;i<n;i++)
{
	for(int j=0;j<m;j++)
	{
		int v;
		cin>>v;
		if(v!=-1)
			a.push_back(v);
	}
	if(a.empty())
	{
		cout<<"NO\n";
		return 0;
	}
	else
	{
		sort(a.begin(),a.end());
		s+=a[0];
		a.clear();
	}

}
if(s>k)
	cout<<"NO\n";
else
	cout<<"YES\n";
return 0;
}
Copy
Omar's Gifts sameh58
GNU G++17
32 ms
944 KB
Accepted