#include <bits/stdc++.h>
using namespace std;
int n, k;
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
int r[n + 1][k + 1];
int u[n + 1][k + 1];
int p[n + 1] = {0};
bool done[n + 1] = {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... |