Submission #1282398

#TimeUsernameProblemLanguageResultExecution timeMemory
1282398ducdevTopical (NOI23_topical)C++17
100 / 100
299 ms90476 KiB
// Author: 4uckd3v - Nguyen Cao Duc #include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() typedef long long ll; typedef pair<int, int> ii; const int MAX_N = 1e6; const int MOD = 1e9 + 7; int n, k; int ptr[MAX_N + 5], cnt[MAX_N + 5]; ll p[MAX_N + 5]; vector<ii> topic[MAX_N + 5]; vector<vector<int>> u; int main() { ios_base::sync_with_stdio(0); cin.tie(0); if (fopen("MAIN.INP", "r")) { freopen("MAIN.INP", "r", stdin); freopen("MAIN.OUT", "w", stdout); }; cin >> n >> k; for (int i = 1; i <= n; i++) { for (int j = 1; j <= k; j++) { int x; cin >> x; topic[j].push_back(ii(x, i)); }; }; u.resize(n + 1, vector<int>(k + 1, 0)); for (int i = 1; i <= n; i++) { for (int j = 1; j <= k; j++) { cin >> u[i][j]; }; }; for (int i = 1; i <= k; i++) sort(all(topic[i])); vector<int> canLearn; int res = 0; while (true) { bool stop = true; for (int i = 1; i <= k; i++) { int& idx = ptr[i]; while (idx < (int)topic[i].size() && p[i] >= topic[i][idx].first) { int module = topic[i][idx].second; cnt[module]++; if (cnt[module] == k) { stop = false; for (int i = 1; i <= k; i++) { p[i] += u[module][i]; }; res++; }; idx++; }; }; if (stop) break; }; cout << res << '\n'; };

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen("MAIN.INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen("MAIN.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...