Submission #1102747

#TimeUsernameProblemLanguageResultExecution timeMemory
1102747ttamxTopical (NOI23_topical)C++17
100 / 100
576 ms132528 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; int main(){ cin.tie(nullptr)->sync_with_stdio(false); int n,m; cin >> n >> m; vector<vector<ll>> a(n,vector<ll>(m)),b(n,vector<ll>(m)); for(auto &v:a)for(auto &x:v)cin >> x; for(auto &v:b)for(auto &x:v)cin >> x; queue<int> q; vector<int> cnt(n); vector<ll> val(m); vector<priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>>> pq(m); for(int i=0;i<n;i++)for(int j=0;j<m;j++)pq[j].emplace(a[i][j],i); auto work=[&](){ for(int i=0;i<m;i++){ while(!pq[i].empty()&&pq[i].top().first<=val[i]){ int v=pq[i].top().second; pq[i].pop(); cnt[v]++; if(cnt[v]==m)q.emplace(v); } } }; work(); int ans=0; while(!q.empty()){ int u=q.front(); q.pop(); ans++; for(int i=0;i<m;i++)val[i]+=b[u][i]; work(); } 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...