Submission #1107428

#TimeUsernameProblemLanguageResultExecution timeMemory
110742812345678Topical (NOI23_topical)C++17
100 / 100
595 ms148516 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") ll n, k, cnt; vector<ll> cur, sm; vector<vector<ll>> r, u; vector<priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>> pq; queue<ll> q; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>k; cur.resize(k); sm.resize(n); pq.resize(k); r.resize(n); u.resize(n); for (int i=0; i<n; i++) r[i].resize(k), u[i].resize(k); for (int i=0; i<n; i++) for (int j=0; j<k; j++) cin>>r[i][j], sm[i]+=r[i][j]; for (int i=0; i<n; i++) for (int j=0; j<k; j++) cin>>u[i][j]; for (int i=0; i<n; i++) { if (sm[i]==0) q.push(i); else pq[0].push({r[i][0], i}); } while (!q.empty()) { while (!q.empty()) { auto x=q.front(); for (int i=0; i<k; i++) cur[i]+=u[x][i]; q.pop(); cnt++; } for (int i=0; i<k; i++) { while (!pq[i].empty()&&pq[i].top().first<=cur[i]) { ll tmp=pq[i].top().second; pq[i].pop(); if (i==k-1) q.push(tmp); else pq[i+1].push({r[tmp][i+1], tmp}); } } } cout<<cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...