Submission #1102255

#TimeUsernameProblemLanguageResultExecution timeMemory
1102255thangdz2k7Topical (NOI23_topical)C++17
100 / 100
484 ms109512 KiB
// 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)

Main.cpp:18:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | void maxl(auto &a, auto b) {a = max(a, b);}
      |           ^~~~
Main.cpp:18:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | void maxl(auto &a, auto b) {a = max(a, b);}
      |                    ^~~~
Main.cpp:19:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void minl(auto &a, auto b) {a = min(a, b);}
      |           ^~~~
Main.cpp:19:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void minl(auto &a, auto b) {a = min(a, b);}
      |                    ^~~~
Main.cpp: In function 'int main()':
Main.cpp:64:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         freopen("pqh.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:65:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |         freopen("pqh.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...