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;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<int> f(n, m);
queue<int> q;
vector<multiset<pair<int, int>>> s(m);
for (int i = 0; i < n; i++) {
vector<int> a(m);
for (int &x : a) {
cin >> x;
}
if (a == vector(m, 0)) {
q.push(i);
} else {
for (int j = 0; j < m; j++) {
s[j].emplace(a[j], i);
}
}
}
vector u(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int &x : u[i]) {
cin >> x;
}
}
int ans = 0;
vector<ll> t(m);
while (!q.empty()) {
int i = q.front();
q.pop();
ans++;
for (int j = 0; j < m; j++) {
t[j] += u[i][j];
while (!s[j].empty() && (*s[j].begin()).first <= t[j]) {
auto [_, k] = *s[j].begin();
s[j].erase(s[j].begin());
if (!--f[k]) {
q.push(k);
}
}
}
}
cout << ans << "\n";
return 6/22;
}
# | 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... |