답안 #929243

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
929243 2024-02-18T04:14:21 Z okkoo Topical (NOI23_topical) C++17
100 / 100
861 ms 123136 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

const int mxn = 1e6;
int can[mxn];

bool compare(pair<int, int> a, pair<int, int> b){
    if(a.first == b.first) return a.second < b.second;
    return a.first > b.first;
}

int main(){
    int n, k;
    cin >> n >> k;
    vector<vector<int> > require(n, vector<int>(k)), gain(n, vector<int>(k));
    queue<int> q;
    vector<vector<pair<int, int> > > tmp(k, vector<pair<int, int> >());
    vector<long long> knowledge(k, 0);
    for(int i=0; i<n; i++){
        for(int j=0; j<k; j++){
            cin >> require[i][j];
            if(!require[i][j]) can[i]++;
            tmp[j].push_back(make_pair(require[i][j], i));
        }
        if(can[i]==k) q.push(i);
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<k; j++) cin >> gain[i][j];
    }
    for(int i=0; i<k; i++){
        sort(tmp[i].begin(), tmp[i].end(), compare);
    }
    int ans = 0;
    while(!q.empty()){
        int cur = q.front(); q.pop();
        ans++;
        for(int i=0; i<k; i++){
            knowledge[i] += gain[cur][i];
            while(!tmp[i].empty() && tmp[i].back().first <= knowledge[i]){
                int module = tmp[i].back().second;
                can[module]++;
                if(can[module] == k) q.push(module);
                tmp[i].pop_back();
            }
        }
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 6 ms 1116 KB Output is correct
4 Correct 527 ms 70880 KB Output is correct
5 Correct 562 ms 70640 KB Output is correct
6 Correct 549 ms 70884 KB Output is correct
7 Correct 372 ms 70796 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 1 ms 348 KB Output is correct
7 Correct 7 ms 604 KB Output is correct
8 Correct 10 ms 604 KB Output is correct
9 Correct 5 ms 600 KB Output is correct
10 Correct 7 ms 616 KB Output is correct
11 Correct 7 ms 660 KB Output is correct
12 Correct 7 ms 648 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 8 ms 1628 KB Output is correct
4 Correct 78 ms 12576 KB Output is correct
5 Correct 78 ms 12572 KB Output is correct
6 Correct 861 ms 123136 KB Output is correct
7 Correct 772 ms 121836 KB Output is correct
8 Correct 811 ms 123124 KB Output is correct
9 Correct 761 ms 122192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 6 ms 1116 KB Output is correct
4 Correct 527 ms 70880 KB Output is correct
5 Correct 562 ms 70640 KB Output is correct
6 Correct 549 ms 70884 KB Output is correct
7 Correct 372 ms 70796 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 1 ms 348 KB Output is correct
14 Correct 7 ms 604 KB Output is correct
15 Correct 10 ms 604 KB Output is correct
16 Correct 5 ms 600 KB Output is correct
17 Correct 7 ms 616 KB Output is correct
18 Correct 7 ms 660 KB Output is correct
19 Correct 7 ms 648 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 8 ms 1628 KB Output is correct
23 Correct 78 ms 12576 KB Output is correct
24 Correct 78 ms 12572 KB Output is correct
25 Correct 861 ms 123136 KB Output is correct
26 Correct 772 ms 121836 KB Output is correct
27 Correct 811 ms 123124 KB Output is correct
28 Correct 761 ms 122192 KB Output is correct
29 Correct 692 ms 18768 KB Output is correct
30 Correct 680 ms 16472 KB Output is correct
31 Correct 689 ms 23096 KB Output is correct
32 Correct 427 ms 18848 KB Output is correct
33 Correct 472 ms 16472 KB Output is correct
34 Correct 503 ms 19848 KB Output is correct
35 Correct 565 ms 23060 KB Output is correct
36 Correct 563 ms 20052 KB Output is correct
37 Correct 650 ms 19792 KB Output is correct
38 Correct 344 ms 25028 KB Output is correct