Submission #1326991

#TimeUsernameProblemLanguageResultExecution timeMemory
1326991yeulerTopical (NOI23_topical)C++20
12 / 100
105 ms20000 KiB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define eb push_back
#define fi first
#define se second
#define vector2d(x) vector<vector<x>>
#define pii pair<int, int>
#define pl pair<ll, ll>
#define kagamine_len ios_base::sync_with_stdio(0); cin.tie(0);
#define file_in freopen("input.txt", "r", stdin);
#define file_out freopen("output.txt", "w", stdout);
#define all(x) x.begin(), x.end()

using namespace std;

/*

g++ -std=c++20 NOI23_Topical.cpp -o output/NOI23_Topical.exe
./output/NOI23_Topical.exe


Input
n -> modules, k -> topics
r1,1, ... r1,k
v       -> untuk modul _ perlu knowledge brp di topic _
rn,1, rn,k
u1,1, ... u1,k
v       -> knowledge yg didapatkan stlh selesai modul _ untuk topic _
un,1, un,k


*/

int n, k;

void solve(){
    vector r(n+1, vector<int>(k+1));
    vector u(n+1, vector<int>(k+1));
    bool udh[n+1];
    memset(udh, 0, sizeof(udh));

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

    bool can = 1;
    vector<int> cur(k+1);
    while (can){
        can = 0;
        for (int i = 1; i <= n; i++){
            if (udh[i]) continue;

            bool req = 1;
            for (int j = 1; j <= k; j++){
                if (r[i][j] > cur[j]){
                    req = 0;
                    break;
                }
            }

            if (req){
                can = 1;
                udh[i] = 1;
                for (int j = 1; j <= k; j++){
                    cur[j] += u[i][j];
                }
            }
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++){
        if (udh[i]) ans++;
    }

    cout << ans << "\n";
}


int main(){
    kagamine_len

    cin >> n >> k;

    solve();

    
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...