#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, k;
pair<int, pair<int, int>> knowledge;
vector<pair<int, pair<int, int>>> r;
vector<pair<int, pair<int, int>>> u;
signed main(){
knowledge.first = 0;
knowledge.second.first = 0;
knowledge.second.second = 0;
cin >> n >> k;
r.resize(n);
u.resize(n);
for(int i = 0; i < n; i++){
cin >> r[i].first >> r[i].second.first >> r[i].second.second;
}
for(int i = 0; i < n; i++){
cin >> u[i].first >> u[i].second.first >> u[i].second.second;
}
vector<bool> done(n, false);
int completed = 0;
bool progress = true;
while(progress){
progress = false;
for(int i = 0; i < n; i++){
if(done[i]){
continue;
}
if(knowledge.first >= r[i].first && knowledge.second.first >= r[i].second.first && knowledge.second.second >= r[i].second.second){
done[i] = true;
completed++;
progress = true;
knowledge.first += u[i].first;
knowledge.second.first += u[i].second.first;
knowledge.second.second += u[i].second.second;
}
}
}
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... |