# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1102825 | blackslex | Topical (NOI23_topical) | C++17 | 1082 ms | 161412 KiB |
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 pii = pair<int, int>;
int n, k;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> k;
vector<vector<int>> r(n + 5, vector<int>(k + 5)), u(n + 5, vector<int>(k + 5));
vector<int> p(k + 5), done(n + 5);
vector<multiset<pii>> ms(k + 5);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= k; j++) {
cin >> r[i][j];
if (r[i][j]) ms[j].emplace(r[i][j], i);
else done[i]++;
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= k; j++) cin >> u[i][j];
}
queue<int> q;
vector<bool> f(n + 5);
for (int i = 1; i <= n; i++) if (done[i] == k) q.emplace(i);
while (!q.empty()) {
int cur = q.front(); q.pop();
if (f[cur]) continue; f[cur] = 1;
for (int j = 1; j <= k; j++) {
p[j] += u[cur][j];
vector<pii> c;
for (auto [x, y]: ms[j]) {
if (x <= p[j]) {
done[y]++;
if (done[y] == k) q.emplace(y);
c.emplace_back(x, y);
} else break;
}
for (auto &e: c) ms[j].erase(e);
}
}
int ans = 0;
for (int i = 1; i <= n; i++) if (f[i]) ans++;
cout << ans;
}
Compilation message (stderr)
# | 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... |