Submission #1099581

# Submission time Handle Problem Language Result Execution time Memory
1099581 2024-10-11T17:50:15 Z coin_ Topical (NOI23_topical) C++14
100 / 100
393 ms 211108 KB
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define endl '\n'

using namespace std;
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<vector<int>> req(n, vector<int>(k + 5, 0)), gain(n + 5, vector<int>(k + 5, 0));
    vector<vector<pair<int, int>>> sortedreq(k + 5, vector<pair<int, int>>());
    vector<int> count(n + 5, 0), cur(k + 5, 0), track(k + 5, 0);
    for (int i = 0; i < n; i++){
        for (int j = 0; j < k; j++){
            cin >> req[i][j];
            sortedreq[j].push_back({req[i][j], i});
        }
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < k; j++){
            cin >> gain[i][j];
        }
    }
    for (int j = 0; j < k; j++){
        sort(sortedreq[j].begin(), sortedreq[j].end());
    }
    int ans = 0;
    while(true){
        int change = 0;
        for (int j = 0; j < k; j++){
            while(track[j] < n && cur[j] >= sortedreq[j][track[j]].fi){
                change = 1;
                int module = sortedreq[j][track[j]].se;
                count[module]++;
                if (count[module] == k){
                    ans++;
                    for (int _ = 0; _ < k; _++){
                        cur[_] += gain[module][_];
                    }
                }
                track[j]++;
            }
        }
        if (change == 0) break;
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 2 ms 1748 KB Output is correct
4 Correct 204 ms 137144 KB Output is correct
5 Correct 209 ms 137144 KB Output is correct
6 Correct 205 ms 137148 KB Output is correct
7 Correct 178 ms 131516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 448 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 860 KB Output is correct
8 Correct 3 ms 860 KB Output is correct
9 Correct 2 ms 728 KB Output is correct
10 Correct 3 ms 904 KB Output is correct
11 Correct 3 ms 860 KB Output is correct
12 Correct 2 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 4 ms 2652 KB Output is correct
4 Correct 37 ms 21652 KB Output is correct
5 Correct 41 ms 21192 KB Output is correct
6 Correct 381 ms 211108 KB Output is correct
7 Correct 361 ms 209464 KB Output is correct
8 Correct 393 ms 211108 KB Output is correct
9 Correct 331 ms 209560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 2 ms 1748 KB Output is correct
4 Correct 204 ms 137144 KB Output is correct
5 Correct 209 ms 137144 KB Output is correct
6 Correct 205 ms 137148 KB Output is correct
7 Correct 178 ms 131516 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 448 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 2 ms 860 KB Output is correct
15 Correct 3 ms 860 KB Output is correct
16 Correct 2 ms 728 KB Output is correct
17 Correct 3 ms 904 KB Output is correct
18 Correct 3 ms 860 KB Output is correct
19 Correct 2 ms 860 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 4 ms 2652 KB Output is correct
23 Correct 37 ms 21652 KB Output is correct
24 Correct 41 ms 21192 KB Output is correct
25 Correct 381 ms 211108 KB Output is correct
26 Correct 361 ms 209464 KB Output is correct
27 Correct 393 ms 211108 KB Output is correct
28 Correct 331 ms 209560 KB Output is correct
29 Correct 192 ms 55176 KB Output is correct
30 Correct 179 ms 49488 KB Output is correct
31 Correct 238 ms 61892 KB Output is correct
32 Correct 146 ms 45960 KB Output is correct
33 Correct 154 ms 42336 KB Output is correct
34 Correct 181 ms 46084 KB Output is correct
35 Correct 232 ms 58560 KB Output is correct
36 Correct 201 ms 49156 KB Output is correct
37 Correct 220 ms 52028 KB Output is correct
38 Correct 157 ms 50880 KB Output is correct