Source Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool solve() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> v(n, 111);
    for (int i = 0; i < n; ++i) {
        for (int j = 0, x; j < m; ++j) {
            cin >> x;
            if (x > 0) v[i] = min(v[i], x);
        }
    }
    for (int i = 0; i < n; ++i) {
        if (v[i] == 111 || k - v[i] < 0) return 0;
        k -= v[i];
    }
    return 1;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cout << (solve() ? "YES" : "NO") << '\n';
    return 0;
}
Copy
Omar's Gifts Heartbeat
GNU G++17
12 ms
884 KB
Wrong Answer