# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1102255 | thangdz2k7 | Topical (NOI23_topical) | C++17 | 484 ms | 109512 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.
// author : thembululquaUwU
// 3.9.2024
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
void maxl(auto &a, auto b) {a = max(a, b);}
void minl(auto &a, auto b) {a = min(a, b);}
int n, k, p[N], can[N], id[N];
vector <pair <int, int>> r[N];
vector <int> u[N];
void solve(){
cin >> n >> k;
for (int i = 0; i < n; ++ i){
for (int j = 0, x; j < k; ++ j){
cin >> x;
r[j].emplace_back(x, i);
}
}
for (int i = 0; i < n; ++ i){
for (int j = 0, x; j < k; ++ j){
cin >> x;
u[i].push_back(x);
}
}
for (int i = 0; i < k; ++ i) sort(r[i].begin(), r[i].end());
int ans = 0;
while (ans < n){
vector <int> pass;
for (int i = 0; i < k; ++ i){
while (id[i] < n && p[i] >= r[i][id[i]].fi){
int t = r[i][id[i]].se;
can[t] ++; id[i] ++;
if (can[t] == k) pass.push_back(t);
}
}
if (pass.empty()) break;
ans += int(pass.size());
for (int i : pass){
for (int j = 0; j < k; ++ j) p[j] = min(mod, p[j] + u[i][j]);
}
}
cout << ans;
}
int main(){
if (fopen("pqh.inp", "r")){
freopen("pqh.inp", "r", stdin);
freopen("pqh.out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t = 1; // cin >> t;
while (t --) solve();
return 0;
}
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... |