| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1282396 | ducdev | Topical (NOI23_topical) | C++17 | 347 ms | 93996 KiB | 
// Author: 4uckd3v - Nguyen Cao Duc
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> ii;
const int MAX_N = 1e6;
const int MOD = 1e9 + 7;
int n, k;
int ptr[MAX_N + 5], cnt[MAX_N + 5];
ll p[MAX_N + 5];
vector<ii> topic[MAX_N + 5];
vector<vector<int>> u;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if (fopen("MAIN.INP", "r")) {
        freopen("MAIN.INP", "r", stdin);
        freopen("MAIN.OUT", "w", stdout);
    };
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            int x;
            cin >> x;
            topic[j].push_back(ii(x, i));
        };
    };
    u.resize(n + 1, vector<int>(k + 1, 0));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            cin >> u[i][j];
        };
    };
    for (int i = 1; i <= k; i++) sort(all(topic[i]));
    vector<int> canLearn;
    int res = 0;
    while (true) {
        for (int i = 1; i <= k; i++) {
            int& idx = ptr[i];
            while (idx < (int)topic[i].size() && p[i] >= topic[i][idx].first) {
                int module = topic[i][idx].second;
                cnt[module]++;
                if (cnt[module] == k) canLearn.push_back(module);
                idx++;
            };
        };
        if (canLearn.empty()) break;
        int module = canLearn.back();
        canLearn.pop_back();
        for (int i = 1; i <= k; i++) {
            p[i] += u[module][i];
        };
        res++;
    };
    cout << res << '\n';
};
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
