Submission #893319

#TimeUsernameProblemLanguageResultExecution timeMemory
893319vjudge1Topical (NOI23_topical)C++17
100 / 100
348 ms110392 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define for1(i,j,k) for(int i=j;i<=k;i++) #define for2(i,j,k) for(int i=j;i>=k;i--) #define for3(i,j,k,l) for(int i=j;i<=k;i+=l) #define bit(n,i) ((n>>i)&1) #define all(x) x.begin(),x.end() #define int long long #define double long double typedef long long ll; typedef pair<int,int> pii; typedef double ld; typedef pair<ld,ld> pdd; typedef pair<ll,ll> pll; const ll maxn=1e6+5; const ll offset=2e5; const ll blk=317; const ll inf=1e9; const int base =311; const ll mod=998244353; int n,k; vector<vector<int>> u; vector<pii> L[maxn]; int p[maxn],cnt[maxn]; void sol() { cin >> n>> k; u.resize(n+2,vector<int>(k+2,0)); for1(i,1,n) { for1(j,1,k) { int x; cin >> x; L[j].pb({x,i}); } } for1(i,1,n) { for1(j,1,k) { cin >> u[i][j]; } } for1(j,1,k) sort(all(L[j]),greater<pii>()); vector<int> qq; int res=0; while (true) { for1(j,1,k) { while (!L[j].empty() && p[j]>= L[j].back().fi) { cnt[L[j].back().se]++; // cerr<< cnt[L[j].back().se]<<' '<<L[j].back().se<<'\n'; if (cnt[L[j].back().se] == k) qq.pb(L[j].back().se); L[j].pop_back(); } } // cerr<< qq.size()<<'\n'; if (qq.empty()) break; while (!qq.empty()) { int i=qq.back(); qq.pop_back(); res++; for1(j,1,k) p[j]+=u[i][j]; } } cout << res<<'\n'; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen("paleta.inp","r",stdin); // freopen("paleta.out","w",stdout); int t=1;//cin >> t; while (t--) { sol(); } } /* 1 5 3 4 1 2 3 1 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...