Submission #1327811

#TimeUsernameProblemLanguageResultExecution timeMemory
1327811illuminastormTopical (NOI23_topical)C++20
12 / 100
399 ms23888 KiB
#include <bits/stdc++.h>
using namespace std;
bool chk(vector<int> a, vector<int> b){
    for(int i=0;i<a.size();i++){
        if(a[i]<b[i]){
            return false;
        }
    }
    return true;
}
int main() {
	// your code goes here
	int n,k;
	cin >> n >> k;
	std::vector<vector<int>> r(n, vector<int>(k));
	std::vector<vector<int>> u(n, vector<int>(k));
	for(int i=0;i<n;i++){
	    for(int j=0;j<k;j++){
	        cin >> r[i][j];
	    }
	}
	for(int i=0;i<n;i++){
	    for(int j=0;j<k;j++){
	        cin >> u[i][j];
	    }
	}
	int ans = 0;
	bool update = false;
	vector<bool> done(n, false);
    vector<int> cur(k, 0);
    while(true){
        update = false;
        for(int i=0;i<n;i++){
            if(done[i]!=true){
                if(chk(cur, r[i])){
                    for(int j=0;j<k;j++){
                        cur[j]=cur[j]+u[i][j];
                    }
                    ans++;
                    update = true;
                    done[i]=true;
                }
            }
        }
        if(update!=true){
            break;
        }
    }
    cout << ans;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...