제출 #1261923

#제출 시각아이디문제언어결과실행 시간메모리
1261923rayan_bdTopical (NOI23_topical)C++20
12 / 100
116 ms39584 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<vector<int>> r(n + 1, vector<int> (k + 1, 0));
    vector<vector<int>> v(n + 1, vector<int> (k + 1, 0));
    vector<int> p(k + 1, 0);
    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 >> v[i][j];
        }
    }
    int ans = 0;
    while(1){
        bool found_any  = 0;
        for(int i = 1; i <= n; ++i){
            int ok = 0;
            for(int j = 1; j <= k; ++j){
                if(p[j] == -1) break;
                if(p[j] >= r[i][j]) ok += 1;
            }
            if(ok == k){
                for(int j = 1; j <= k; ++j){
                    p[j] += v[i][j];
                    p[j] = -1;
                }
                ans += 1;
                found_any = 1;
            }
        }
        if(!found_any) break;
    }
    cout << ans << "\n";
    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...