제출 #1218427

#제출 시각아이디문제언어결과실행 시간메모리
1218427cpismayilmmdv985Topical (NOI23_topical)C++20
100 / 100
413 ms125728 KiB
#include <bits/stdc++.h> int main() { using namespace std; ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int N, K, res = 0; cin >> N >> K; vector<vector<int>> U(N, vector<int> (K)), R(N, vector<int> (K)); vector<priority_queue<array<int, 2>, vector<array<int, 2>>, greater<array<int, 2>>>> pq(K); for (int i = 0; i < N; i++) { for (int j = 0; j < K; j++) { cin >> R[i][j]; pq[j].push({R[i][j], i}); } } for (int i = 0; i < N; i++) for (int j = 0; j < K; j++) cin >> U[i][j]; vector<int64_t> P(K), cnt(N); while (true) { bool flag = false; for (int j = 0; j < K; j++) { while (!pq[j].empty()) { array<int, 2> curr = pq[j].top(); if (P[j] >= curr[0]) { cnt[curr[1]]++; pq[j].pop(); flag = true; if (cnt[curr[1]] == K) { res++; for (int k = 0; k < K; k++) P[k] += U[curr[1]][k]; } } else break; } } if (!flag) break; } cout << res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...