Submission #1102455

# Submission time Handle Problem Language Result Execution time Memory
1102455 2024-10-18T07:28:17 Z ShadowShark Topical (NOI23_topical) C++17
100 / 100
359 ms 92052 KB
#include <bits/stdc++.h>
using namespace std;

const int maxN = 1e6 + 5;
bool cmp(pair<int, int> A, pair<int, int> B) {
    return A.first > B.first;
}
vector<int> inc[maxN];
vector<pair<int, int>> col[maxN];
int cnt[maxN], skill[maxN];

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

    int n, k;
    cin >> n >> k;

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            int x;
            cin >> x;

            col[j].push_back({x, i});
        }
    }

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= k; j++) {
            int x;
            cin >> x;

            inc[i].push_back(x);
    }

    for (int i = 1; i <= k; i++)
        sort(col[i].begin(), col[i].end(), cmp);


    int ans = 0;
    queue<int> Q;
    do {
        for (int i = 1; i <= k; i++) {
            if (col[i].size() == 0) continue ;
            while (col[i].size() > 0) {
                auto it = col[i].back();
                if (it.first <= skill[i]) {
                    col[i].pop_back();
                    cnt[it.second]++;
                    if (cnt[it.second] == k) Q.push(it.second);
                }
                else break;
            }
        }

        if (Q.size() == 0) break;
        while (Q.size() != 0) {
            int id = Q.front(); Q.pop();
            for (int i = 1; i <= k; i++)
                skill[i] += inc[id][i - 1];
            ans++;
        }
    } while (true);

    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 48720 KB Output is correct
2 Correct 10 ms 48720 KB Output is correct
3 Correct 12 ms 49232 KB Output is correct
4 Correct 180 ms 88128 KB Output is correct
5 Correct 177 ms 88252 KB Output is correct
6 Correct 167 ms 88128 KB Output is correct
7 Correct 130 ms 86448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 48720 KB Output is correct
2 Correct 8 ms 48720 KB Output is correct
3 Correct 10 ms 48720 KB Output is correct
4 Correct 9 ms 48856 KB Output is correct
5 Correct 9 ms 48720 KB Output is correct
6 Correct 9 ms 48888 KB Output is correct
7 Correct 10 ms 49104 KB Output is correct
8 Correct 11 ms 48976 KB Output is correct
9 Correct 10 ms 48976 KB Output is correct
10 Correct 10 ms 49100 KB Output is correct
11 Correct 12 ms 48976 KB Output is correct
12 Correct 10 ms 49100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 48720 KB Output is correct
2 Correct 9 ms 48720 KB Output is correct
3 Correct 12 ms 49232 KB Output is correct
4 Correct 37 ms 53196 KB Output is correct
5 Correct 37 ms 53196 KB Output is correct
6 Correct 302 ms 92052 KB Output is correct
7 Correct 314 ms 90800 KB Output is correct
8 Correct 312 ms 91992 KB Output is correct
9 Correct 359 ms 90800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 48720 KB Output is correct
2 Correct 10 ms 48720 KB Output is correct
3 Correct 12 ms 49232 KB Output is correct
4 Correct 180 ms 88128 KB Output is correct
5 Correct 177 ms 88252 KB Output is correct
6 Correct 167 ms 88128 KB Output is correct
7 Correct 130 ms 86448 KB Output is correct
8 Correct 8 ms 48720 KB Output is correct
9 Correct 8 ms 48720 KB Output is correct
10 Correct 10 ms 48720 KB Output is correct
11 Correct 9 ms 48856 KB Output is correct
12 Correct 9 ms 48720 KB Output is correct
13 Correct 9 ms 48888 KB Output is correct
14 Correct 10 ms 49104 KB Output is correct
15 Correct 11 ms 48976 KB Output is correct
16 Correct 10 ms 48976 KB Output is correct
17 Correct 10 ms 49100 KB Output is correct
18 Correct 12 ms 48976 KB Output is correct
19 Correct 10 ms 49100 KB Output is correct
20 Correct 9 ms 48720 KB Output is correct
21 Correct 9 ms 48720 KB Output is correct
22 Correct 12 ms 49232 KB Output is correct
23 Correct 37 ms 53196 KB Output is correct
24 Correct 37 ms 53196 KB Output is correct
25 Correct 302 ms 92052 KB Output is correct
26 Correct 314 ms 90800 KB Output is correct
27 Correct 312 ms 91992 KB Output is correct
28 Correct 359 ms 90800 KB Output is correct
29 Correct 202 ms 63564 KB Output is correct
30 Correct 203 ms 61000 KB Output is correct
31 Correct 265 ms 65000 KB Output is correct
32 Correct 149 ms 63560 KB Output is correct
33 Correct 175 ms 60956 KB Output is correct
34 Correct 185 ms 64336 KB Output is correct
35 Correct 245 ms 64900 KB Output is correct
36 Correct 206 ms 64384 KB Output is correct
37 Correct 220 ms 64292 KB Output is correct
38 Correct 143 ms 65008 KB Output is correct