Submission #946870

#TimeUsernameProblemLanguageResultExecution timeMemory
946870josanneo22Topical (NOI23_topical)C++17
12 / 100
121 ms31684 KiB
#include <bits/stdc++.h> using namespace std; using i64 = long long; #define L(i, j, k) for (int i = (j); i <= (k); ++i) #define R(i, j, k) for (int i = (j); i >= (k); --i) #define rep0(i, n) L(i, 0, n - 1) #define rep1(i, n) L(i, 1, n) int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, k; cin >> n >> k; vector<vector<i64>> r(n, vector<i64>(k)), u(n, vector<i64>(k)); rep0(i, n) rep0(j, k) cin >> r[i][j]; rep0(i, n) rep0(j, k) cin >> u[i][j]; vector<int> ord(n); iota(ord.begin(), ord.end(), 0); sort(ord.begin(), ord.end(), [&](int i, int j){ rep0(p, k) if(r[i][p] != r[j][p]) return r[i][p] < r[j][p]; return true; }); vector<i64> sum(k); vector<bool> vis(n); int ans = 0; rep1(loop, n){ // cout << "loop " << loop << '\n'; for (auto & i : ord) { if (vis[i]) continue; // cout << "try : " << i + 1 << '\n'; bool ok = true; rep0(j, k) if (r[i][j] > sum[j]) ok = false; if (ok) { // cout << "eat : " << i + 1 << '\n'; vis[i] = true; rep0(j, k) sum[j] += u[i][j]; // rep0(j, k) cout << sum[j] << " \n"[j == k - 1]; ans++; } } } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...