답안 #1099204

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099204 2024-10-10T18:03:54 Z NoMercy Topical (NOI23_topical) C++17
100 / 100
416 ms 137904 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

bool cmp (array<int, 2> a, array<int, 2> b) {
    if (a[0] == b[0]) return a[1] < b[1];
    return a[0] > b[0];
}

int32_t main () {

    ios_base::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0); 

    int N, M;
    cin >> N >> M;
    vector<vector<int>> r(N, vector<int> (M, 0)), u(N, vector<int> (M, 0));
    vector<int> say(N, 0), p(M, 0);
    queue<int> q;
    vector<vector<array<int, 2>>> tmp(M);
    for (int i = 0;i < N;i ++) {
        for (int j = 0;j < M;j ++) {
            cin >> r[i][j];
            if (r[i][j] == 0) {
                say[i] ++;
            }
            tmp[j].push_back({r[i][j], i});
        }
        if (say[i] == M) {
            q.push(i);
        }
    }
    for (int i = 0;i < N;i ++) {
        for (int j = 0;j < M;j ++) {
            cin >> u[i][j];
        }
    }
    for (int j = 0;j < M;j ++) {
        sort (tmp[j].begin(), tmp[j].end(), cmp);
    }
    int result = 0;
    while (q.size() > 0) {
        auto it = q.front();
        q.pop();
        result ++;
        for (int j = 0;j < M;j ++) {
            p[j] += u[it][j];
            while (tmp[j].size() > 0 && tmp[j].back()[0] <= p[j]) {
                say[tmp[j].back()[1]] ++;
                if (say[tmp[j].back()[1]] == M) {
                    q.push(tmp[j].back()[1]);
                }
                tmp[j].pop_back();
            }
        }
    }
    cout << result << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 1128 KB Output is correct
4 Correct 156 ms 78444 KB Output is correct
5 Correct 158 ms 78604 KB Output is correct
6 Correct 162 ms 78600 KB Output is correct
7 Correct 129 ms 72712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 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 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 704 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 2 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 4 ms 1844 KB Output is correct
4 Correct 34 ms 14024 KB Output is correct
5 Correct 34 ms 13776 KB Output is correct
6 Correct 416 ms 137900 KB Output is correct
7 Correct 411 ms 135084 KB Output is correct
8 Correct 409 ms 137904 KB Output is correct
9 Correct 390 ms 135088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 1128 KB Output is correct
4 Correct 156 ms 78444 KB Output is correct
5 Correct 158 ms 78604 KB Output is correct
6 Correct 162 ms 78600 KB Output is correct
7 Correct 129 ms 72712 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 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 604 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 2 ms 704 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 2 ms 600 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 4 ms 1844 KB Output is correct
23 Correct 34 ms 14024 KB Output is correct
24 Correct 34 ms 13776 KB Output is correct
25 Correct 416 ms 137900 KB Output is correct
26 Correct 411 ms 135084 KB Output is correct
27 Correct 409 ms 137904 KB Output is correct
28 Correct 390 ms 135088 KB Output is correct
29 Correct 191 ms 36688 KB Output is correct
30 Correct 217 ms 33552 KB Output is correct
31 Correct 258 ms 38132 KB Output is correct
32 Correct 164 ms 27480 KB Output is correct
33 Correct 170 ms 26452 KB Output is correct
34 Correct 201 ms 29664 KB Output is correct
35 Correct 222 ms 34524 KB Output is correct
36 Correct 195 ms 32592 KB Output is correct
37 Correct 218 ms 35456 KB Output is correct
38 Correct 179 ms 26868 KB Output is correct