#include <bits/stdc++.h>
#define int long long
#define re(a, b, c, d) for (auto a = b; a <= c; a += d)
#define de(a, b, c, d) for (auto a = b; a >= c; a -= d)
#define ms (a); memset (a, 0, sizeof a);
#define imax INT_MAX
#define imin INT_MIN
#define wh(a) while (a --)
#define PII pair <int, int>
#define F first
#define S second
#define pb push_back
#define eb emplace_back
template <typename T> bool chkmin (T &a, T b) {
return (b < a) ? a = b, 1 : 0;
}
template <typename T> bool chkmax (T &a, T b) {
return (b > a) ? a = b, 1 : 0;
}
using namespace std;
const int N = 1e5 + 5;
int T, n, k, c[N], d[N], f[N];
vector <PII> g[N];
signed main () {
cout << fixed << setprecision (0);
ios :: sync_with_stdio (0), cin.tie (0), cout.tie (0);
cin >> n >> k;
int a[n + 5][k + 5], b[n + 5][k + 5];
memset (a, 0, sizeof a);
memset (b, 0, sizeof b);
re (i, 1, n, 1) re (j, 1, k, 1) cin >> a[i][j], g[j].pb ({a[i][j], i});
re (i, 1, n, 1) re (j, 1, k, 1) cin >> b[i][j];
re (i, 1, k, 1)sort (g[i].begin(), g[i].end());
int res = 0;
while (1) {
int fl = 0;
re (i, 1, k, 1) {
while (1) {
if (c[i] >= n || f[i] < g[i][c[i]].F) break;
int h = g[i][c[i]].S;
d[h]++;
if (d[h] == k) {
re (j, 1, k, 1) f[j] += b[h][j];
fl = 1;
res++;
}
c[i]++;
}
}
if (! fl) break;
}
cout << res;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4700 KB |
Output is correct |
2 |
Correct |
1 ms |
4700 KB |
Output is correct |
3 |
Correct |
3 ms |
5980 KB |
Output is correct |
4 |
Runtime error |
152 ms |
213072 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4696 KB |
Output is correct |
2 |
Correct |
1 ms |
4708 KB |
Output is correct |
3 |
Correct |
1 ms |
4700 KB |
Output is correct |
4 |
Correct |
1 ms |
4524 KB |
Output is correct |
5 |
Correct |
1 ms |
4700 KB |
Output is correct |
6 |
Correct |
1 ms |
4524 KB |
Output is correct |
7 |
Correct |
3 ms |
4956 KB |
Output is correct |
8 |
Correct |
3 ms |
4956 KB |
Output is correct |
9 |
Correct |
3 ms |
5032 KB |
Output is correct |
10 |
Correct |
3 ms |
4968 KB |
Output is correct |
11 |
Correct |
3 ms |
4952 KB |
Output is correct |
12 |
Correct |
3 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4700 KB |
Output is correct |
2 |
Correct |
1 ms |
4700 KB |
Output is correct |
3 |
Correct |
4 ms |
5980 KB |
Output is correct |
4 |
Correct |
28 ms |
16088 KB |
Output is correct |
5 |
Correct |
27 ms |
16088 KB |
Output is correct |
6 |
Runtime error |
363 ms |
232460 KB |
Execution killed with signal 11 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4700 KB |
Output is correct |
2 |
Correct |
1 ms |
4700 KB |
Output is correct |
3 |
Correct |
3 ms |
5980 KB |
Output is correct |
4 |
Runtime error |
152 ms |
213072 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |