제출 #1301045

#제출 시각아이디문제언어결과실행 시간메모리
1301045joshjuiceTopical (NOI23_topical)C++20
100 / 100
643 ms86516 KiB
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> pii; const int mxnk=5e6+5; int n, k; int r[mxnk], u[mxnk], f[mxnk], c[mxnk], ind[mxnk]; vector<pii> rq[mxnk]; #define R(i,j) r[i*k+j] #define U(i,j) u[i*k+j] #define fi first #define se second #define ALL(x) x.begin(), x.end() int32_t main() { cin >> n >> k; for (int i = 0; i < n; ++i) { for (int j = 0; j < k; ++j) { cin >> R(i, j); rq[j].emplace_back(R(i, j), i); } } for (int j = 0; j < k; ++j) sort(ALL(rq[j])); for (int i = 0; i < n; ++i) { for (int j = 0; j < k; ++j) cin >> U(i, j); } int a = 0; bool can = 1; while (can) { // while at least one topic is passed can = 0; for (int j = 0; j < k; ++j) { //pass as many times as u can while (ind[j] < n && rq[j][ind[j]].fi <= c[j]) { //check if all modules are passed f[rq[j][ind[j]].se]++; if (f[rq[j][ind[j]].se] == k) { for (int jj = 0; jj < k; ++jj) c[jj] += U(rq[j][ind[j]].se, jj); // update a++; can = 1; } ind[j]++; //go to the next module } } } cout << a; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...