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;
#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;
}
# | 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... |