제출 #1333974

#제출 시각아이디문제언어결과실행 시간메모리
1333974michael12Topical (NOI23_topical)C++20
12 / 100
125 ms23764 KiB
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<stack>
#include<queue>
#include<array>
#include<algorithm>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define int long long
using namespace std;
const int maxn = 1e6 + 10;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    int r[n][k][2];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < k; j++){
            cin >> r[i][j][0];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < k; j++){
            cin >> r[i][j][1];
        }
    }
    vector<bool> used(n, false);
    vector<int> cur(k, 0);
    int ans = 0;
    for (int j = 0; j < k; j++){  
        vector<pair<int,int>> col;
        for (int i = 0; i < n; i++){
            col.push_back({r[i][j][0], r[i][j][1]});
        }
        sort(col.begin(), col.end()); 
        for (int i = 0; i < n; i++){
            r[i][j][0] = col[i].first;
            r[i][j][1] = col[i].second;
        }
    }
    for(int i = 0; i < n; i++){
        int p = 0;
        for(int j = 0; j < n; j++){
            if(cur[j] < r[i][j][0]){
                p += 1;
            }
        }
        if(!used[i] && p == 0){
           for(int j = 0; j < k; j++){
            cur[j] += r[i][j][1];
           }
           ans += 1;
        }
        used[i] = true;
    }
    cout << ans;



    


}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...