# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
862326 | quandlm | Topical (NOI23_topical) | C++17 | 585 ms | 233888 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>
#define file(name) if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
#define ll long long
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, a, b) for (int i = (a); i >= (b); --i)
#define pi pair<int,int>
#define ple tuple<int,int,int>
#define fi first
#define se second
#define ii make_pair
#define isz(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
using namespace std;
const int N = 1e6 + 10;
int n,k;
int p[N], cnt[N];
vector<vector<int>> a,b;
priority_queue<pi,vector<pi>,greater<pi>> pq[N];
int main () {
file("seq");
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> k;
a.assign(n+10,vector<int>(k+10));
b.assign(n+10,vector<int>(k+10));
FOR(i,1,n) {
FOR(j,1,k) {
cin >> a[i][j];
pq[j].push({a[i][j], i});
}
}
FOR(i,1,n) {
FOR(j,1,k) cin >> b[i][j];
}
int res = 0;
while(1) {
vector<int> solved = {};
FOR(j,1,k) {
while(!pq[j].empty() && p[j] >= pq[j].top().fi) {
pi it = pq[j].top(); pq[j].pop();
cnt[it.se]++;
if (cnt[it.se] == k) {
solved.push_back(it.se);
}
}
}
for (int i : solved) {
FOR(j,1,k) {
p[j] += b[i][j];
}
}
res += isz(solved);
if (isz(solved) == 0) break;
}
cout << res << '\n';
}
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... |