#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, k;
vector<vector<int>> r, u;
vector<int> p;
vector<bool> done;
signed main(){
cin >> n >> k;
r.resize(n, vector<int>(k));
u.resize(n, vector<int>(k));
p.assign(k, 0);
done.assign(n, false);
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 completed = 0;
bool progress = true;
while(progress){
progress = false;
for(int i = 0; i < n; i++){
if(done[i]){
continue;
}
bool can = true;
for(int j = 0; j < k; j++){
if(p[j] < r[i][j]){
can = false;
}
}
if(can){
done[i] = true;
completed++;
progress = true;
for(int j = 0; j < k; j++){
p[j] += u[i][j];
}
}
}
}
cout << completed;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |