Submission #966870

#TimeUsernameProblemLanguageResultExecution timeMemory
966870TB_Topical (NOI23_topical)C++17
100 / 100
432 ms152052 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define fo(i, n) for(ll i = 0; i<(n); i++) #define deb(x) cout << #x << " = " << (x) << endl #define deb2(x, y) cout << #x << " = " << (x) << ", " << #y << " = " << y << endl #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define F first #define S second typedef vector<ll> vl; typedef vector<vl> vvl; typedef pair<ll, ll> pl; typedef vector<pl> vpl; typedef vector<vpl> vvpl; int main(){ cin.tie(0)->sync_with_stdio(0); int n, k; cin >> n >> k; vvl r(n, vl(k)), u(n, vl(k)); vvpl cost(k); queue<ll> onQueue; vl am(n, 0); ll ans = 0; fo(i, n){ bool allZero = 1; fo(j, k){ cin >> r[i][j]; if(r[i][j]) allZero = 0; cost[j].pb({r[i][j], i}); } if(allZero){ onQueue.push(i); am[i] = k+1; } } fo(i, n){ fo(j, k){ cin >> u[i][j]; } } fo(i, k) sort(rall(cost[i])); vl p(k, 0); while(!onQueue.empty()){ ll current = onQueue.front(); onQueue.pop(); ans++; fo(i, k){ p[i]+=u[current][i]; while(cost[i].size() && cost[i][cost[i].size()-1].F<=p[i]){ ll pos = cost[i][cost[i].size()-1].S; cost[i].pop_back(); am[pos]++; if(am[pos] == k) onQueue.push(pos); } } } cout << ans; 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...