제출 #1334039

#제출 시각아이디문제언어결과실행 시간메모리
1334039michael12Topical (NOI23_topical)C++20
12 / 100
102 ms12032 KiB
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<stack>
#include<queue>
#include<array>
#include<algorithm>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define int int
using namespace std;
const int maxn = 1e6 + 10;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<vector<int>> r(n, vector<int>(k));
    vector<vector<int>> u(n, vector<int>(k));

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

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

    vector<int> p(k, 0);
    vector<bool> used(n, false);

    int ans = 0;
    bool T = true;

    while (T) {
        T = false;

        for (int i = 0; i < n; i++){
            if (used[i]) continue;
            bool ok = true;
            for (int j = 0; j < k; j++){
                if (p[j] < r[i][j]) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                used[i] = true;
                ans++;
                T = true;

                for (int j = 0; j < k; j++)
                    p[j] += u[i][j];
            }
        }
    }

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