| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1334141 | viettrung | Topical (NOI23_topical) | C++20 | 300 ms | 78712 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define f(i, a, b) for(int i = a; i <= b; i++)
#define fi first
#define se second
#define mll map<ll, ll>
#define sll set<ll>
const ll du = 1e9 + 7;
const ll ars = 1e6 + 5;
int n, k;
vector<ll> a[ars];
int cs[ars];
vector<pll> lis[ars];
ll cur[ars], f[ars];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define task "tenshi"
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
cin >> n >> k;
for(int i = 0; i < k; i++)
lis[i].reserve(n);
for(int i = 0; i < n; i++){
for(int j = 0; j < k; j++){
ll r; cin >> r;
lis[j].pb({r, i});
}
}
for(int j = 0; j < k; j++)
sort(lis[j].begin(), lis[j].end());
for(int i = 0; i < n; i++){
a[i].reserve(k);
for(int j = 0; j < k; j++){
ll v; cin >> v;
a[i].pb(v);
}
}
int ans = 0;
bool ok = true;
while(ok){
ok = false;
for(int j = 0; j < k; j++){
while(cs[j] < lis[j].size() && lis[j][cs[j]].fi <= cur[j]){
ok = true;
auto[val, id] = lis[j][cs[j]];
cs[j]++;
f[id]++;
if(f[id] == k){
ans++;
for(int j2 = 0; j2 < k; j2++)
cur[j2] += a[id][j2];
}
}
}
}
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... | ||||
