#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n, k, cnt;
vector<ll> cur, p, vs;
vector<vector<ll>> r, u;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>k;
cur.resize(k);
p.resize(n);
vs.resize(n);
r.resize(n);
u.resize(n);
for (int i=0; i<n; i++) r[i].resize(k), u[i].resize(k);
for (int i=0; i<n; i++) for (int j=0; j<k; j++) cin>>r[i][j];
for (int i=0; i<n; i++) for (int j=0; j<k; j++) cin>>u[i][j];
while (1)
{
ll progress=0;
for (int i=0; i<n; i++)
{
while (p[i]<k&&cur[p[i]]>=r[i][p[i]]) p[i]++;
if (!vs[i]&&p[i]==k)
{
vs[i]=1;
cnt++;
for (int j=0; j<k; j++) cur[j]+=u[i][j];
progress=1;
}
}
if (!progress) break;
}
cout<<cnt;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
3 ms |
592 KB |
Output is correct |
4 |
Correct |
138 ms |
33108 KB |
Output is correct |
5 |
Correct |
112 ms |
33096 KB |
Output is correct |
6 |
Correct |
115 ms |
33096 KB |
Output is correct |
7 |
Correct |
109 ms |
29768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
456 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
728 KB |
Output is correct |
8 |
Correct |
2 ms |
592 KB |
Output is correct |
9 |
Correct |
2 ms |
592 KB |
Output is correct |
10 |
Correct |
2 ms |
592 KB |
Output is correct |
11 |
Correct |
3 ms |
764 KB |
Output is correct |
12 |
Correct |
3 ms |
592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
4 ms |
1876 KB |
Output is correct |
4 |
Correct |
34 ms |
14256 KB |
Output is correct |
5 |
Execution timed out |
1072 ms |
14160 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
3 ms |
592 KB |
Output is correct |
4 |
Correct |
138 ms |
33108 KB |
Output is correct |
5 |
Correct |
112 ms |
33096 KB |
Output is correct |
6 |
Correct |
115 ms |
33096 KB |
Output is correct |
7 |
Correct |
109 ms |
29768 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
456 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
2 ms |
728 KB |
Output is correct |
15 |
Correct |
2 ms |
592 KB |
Output is correct |
16 |
Correct |
2 ms |
592 KB |
Output is correct |
17 |
Correct |
2 ms |
592 KB |
Output is correct |
18 |
Correct |
3 ms |
764 KB |
Output is correct |
19 |
Correct |
3 ms |
592 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
4 ms |
1876 KB |
Output is correct |
23 |
Correct |
34 ms |
14256 KB |
Output is correct |
24 |
Execution timed out |
1072 ms |
14160 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |