| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1287354 | hehehe147 | Topical (NOI23_topical) | C++20 | 166 ms | 78728 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 1e6 + 7;
int n, k;
vector<vector<int>> r, u;
void read() {
cin >> n >> k;
r = u = vector<vector<int>>(n + 1, vector<int>(k + 1));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= k; j++) {
cin >> r[i][j];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= k; j++) {
cin >> u[i][j];
}
}
}
int p[MAXN], cnt[MAXN];
vector<pair<int, int>> tp[MAXN];
int pt[MAXN];
void addM(int i) {
for (int j = 1; j <= k; j++) {
p[j] += u[i][j];
}
}
bool hehe() {
bool flag = false;
for (int i = 1; i <= k; i++) {
while (pt[i] < tp[i].size() && p[i] >= tp[i][pt[i]].first) {
int idx = tp[i][pt[i]].second;
cnt[idx]++;
if (cnt[idx] == k) {
addM(idx);
flag = true;
}
pt[i]++;
}
}
return flag;
}
void solve() {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= k; j++) {
tp[j].push_back({r[i][j], i});
}
}
for (int i = 1; i <= k; i++) {
sort(tp[i].begin(), tp[i].end());
}
// for (int i = 1; i <= k; i++) {
// cout << i << ": \n";
// for (auto [x, id] : tp[i]) {
// cout << x << " " << id << "\n";
// }
// }
while (hehe());
int ans = 0;
for (int i = 1; i <= n; i++) {
ans += (cnt[i] == k);
}
cout << ans << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("topic.inp", "r")) {
freopen("topic.inp", "r", stdin);
freopen("topic.out", "w", stdout);
}
read();
solve();
}
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... | ||||
