#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 |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
10 ms |
1592 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |