#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
int n, k;
cin >> n >> k;
vector<vector<int>> r(n+1, vector<int>(k+1)), u(n+1, vector<int>(k+1));
for (int i = 1;i<=n;++i){
for (int j = 1;j<=k;++j){
cin >> r[i][j];
}
}
for (int i = 1;i<=n;++i){
for (int j = 1;j<=k;++j){
cin >> u[i][j];
}
}
vector<bool> c(n+1, false);
vector<int> p(k+1, 0);
int dem = 0;
while(true){
bool sol = false;
for (int i = 1;i<=n;++i){
if(!c[i]){
bool check = true;
for (int j = 1;j<=k;++j){
if(r[i][j] > p[j]){
check = false;
break;
}
}
if(check){
for (int j = 1;j<=k;++j){
p[j] += u[i][j];
}
dem++;
sol = true;
c[i] = true;
}
}
}
if(!sol){
cout << dem;
return 0;
}
}
}
| # | 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... |