Submission #1316776

#TimeUsernameProblemLanguageResultExecution timeMemory
1316776vaishakhvTopical (NOI23_topical)C++20
12 / 100
108 ms23824 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

bool comp(pair<ll,ll> a, pair<ll,ll> b){
    ll r1 = a.first, u1 = a.second;
    ll r2 = b.first, u2 = b.second;
    if (r1 != r2) return r1 < r2;
    return u2 < u1;
}

int main() {
	ios::sync_with_stdio(0);
    cin.tie(0);

    ll n, k; cin >> n >> k;
    vector<vector<ll>> r(n, vector<ll>(k, 0)), u(n, vector<ll>(k, 0));

    for (ll i{}; i < n; i++){
        for (ll j{}; j < k; j++){
            cin >> r[i][j];
        }
    }

    for (ll i{}; i < n; i++){
        for (ll j{}; j < k; j++){
            cin >> u[i][j];
        }
    }

    vector<pair<ll,ll>> sortstuff;

    for (ll i{}; i < n; i++){
        pair<ll,ll> a = {r[i][0], u[i][0]};
        sortstuff.push_back(a);
    }

    sort(sortstuff.begin(), sortstuff.end(), comp);

    ll can = 0, mine = 0;
    for (ll i{}; i < n; i++){
        if (i == 0){
            if (sortstuff[0].first == 0) { mine += sortstuff[0].first; can++; continue; }
            else break;
        }

        if (sortstuff[i].first > mine) break;
        can++;
    }

    cout << can;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...