| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1313471 | lev | Topical (NOI23_topical) | C++20 | 359 ms | 133656 KiB |
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int, int>
#define all(a) a.begin(), a.end()
using namespace std;
#ifdef LOCAL
#include "C:\Users\Dell\Downloads\template\template\icpc-notebook\Utilities\debug.h"
#else
#define debug(...) 42
#endif
const int mn = 1e6 + 5, mod = 1e9 + 7, inf = 2e9;
int n, k, cur[mn], val[mn], sum[mn];
vector <vector<int>> r, u;
vector <pii> calc[mn];
void solve() {
cin >> n >> k;
r.resize(n + 1, vector <int> (k + 1));
u.resize(n + 1, vector <int> (k + 1));
for(int i = 1; i <= n; i++){
for(int j = 1; j <= k; j++){
cin >> u[i][j];
calc[j].push_back({u[i][j], i});
}
}
for(int i = 1; i <= k; i++) sort(all(calc[i]));
for(int i = 1; i <= n; i++){
for(int j = 1; j <= k; j++){
cin >> r[i][j];
}
}
int ans = 0;
for(int id = 1; id <= n; id++){
bool check = false;
for(int i = 1; i <= k; i++){
while(cur[i] < n && calc[i][cur[i]].fi <= val[i]){
debug(i, cur[i], calc[i][cur[i]].fi, calc[i][cur[i]].se, val[i]);
int j = calc[i][cur[i]].se;
sum[j] ++;
if(sum[j] == k){
ans ++;
check = true;
for(int i2 = 1; i2 <= k; i2++) val[i2] += r[j][i2];
}
cur[i] ++;
}
}
if(!check) break;
}
cout << ans << '\n';
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
#define task "Kawabata"
if (fopen(task".INP", "r")) {
freopen(task".INP", "r", stdin);
freopen(task".OUT", "w", stdout);
}
int t = 1;
// cin >> t;
while (t--) solve();
return 0;
}
// Don't wanna lose anymore T_T
// Never let me go - Kazuo Ishiguro
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... | ||||
