This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> a, b;
vector<int> cur, id;
int main() {
int n, k, t;
cin >> n >> k;
cur.resize(n + 1, 0);
for(int i = 1; i <= n; i++)
id.push_back(i);
a.resize(n + 1, vector<int> (1, INT_MAX));
for(int i = 1; i <= n; i++)
for(int j = 1; j <= k; j++) {
cin >> t;
a[i].push_back(t);
a[i][0] = min(a[i][0], t);
}
b.resize(n + 1, vector<int> (1, INT_MAX));
for(int i = 1; i <= n; i++)
for(int j = 1; j <= k; j++) {
cin >> t;
b[i].push_back(t);
b[i][0] = min(b[i][0], t);
}
sort(id.begin(), id.end(), [&](int i, int j) { return a[i][0] < a[j][0]; });
int ans = 0;
for(int i : id) {
bool can = true;
for(int j = 1; j <= k; j++)
if(cur[j] < a[i][j])
can = false;
if(can) {
for(int j = 1; j <= k; j++)
cur[j] += b[i][j];
ans++;
}
}
cout << ans << endl;
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... |