답안 #929241

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
929241 2024-02-18T04:12:13 Z okkoo Topical (NOI23_topical) C++17
12 / 100
567 ms 74744 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]){
                can[i]++;
                if(can[i] == k) q.push(tmp[i].back().second);
                tmp[i].pop_back();
            }
        }
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 6 ms 1112 KB Output is correct
4 Correct 559 ms 74744 KB Output is correct
5 Correct 531 ms 74620 KB Output is correct
6 Correct 567 ms 74640 KB Output is correct
7 Correct 347 ms 70668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 6 ms 1112 KB Output is correct
4 Correct 559 ms 74744 KB Output is correct
5 Correct 531 ms 74620 KB Output is correct
6 Correct 567 ms 74640 KB Output is correct
7 Correct 347 ms 70668 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -