제출 #1211999

#제출 시각아이디문제언어결과실행 시간메모리
1211999al95ireyizTopical (NOI23_topical)C++20
33 / 100
552 ms133708 KiB
//*** Bismillah ***// #pragma GCC optimize("O3", "fast-math", "unroll-loops", "no-stack-protector") #include <bits/stdc++.h> using namespace std; #if !defined(ONLINE_JUDGE) and !defined(EVAL) #include "template/debug.h" #else #define d(x...) #endif #define fr first #define er erase #define sc second #define in insert #define ll long long #define pb push_back #define vll vector<ll> #define pll pair<ll,ll> #define ull unsigned ll #define vpll vector<pll> #define len(x) (ll) x.size() #define all(x) x.begin(),x.end() const ll INF = 1e9; const ll INFL = 1e18; const ll MOD = 1e9+7; // const ll MOD = 998244353; const ll maxn = 1e6+5; ll n,m,k=0; ll vis[maxn]; void _(ll tt) { cin >> n >> m; vector<vll> v(n + 1, vll(m + 1)), s(n + 1, vll(m + 1)); vll nw(m + 1); vector<priority_queue<pll, vpll, greater<pll>>>q(m + 1); for(ll i = 1; i <= n; i ++){ for(ll j = 1; j <= m; j ++){ cin >> v[i][j]; q[j].push({v[i][j], i}); } } for(ll i = 1; i <= n; i ++){ for(ll j = 1; j <= m; j ++){ cin >> s[i][j]; } } ll cv = 0, f = 1; while(f){ f = 0; for(ll i = 1; i <= m; i ++){ while(!q[i].empty() and vis[q[i].top().sc]) q[i].pop(); if(q[i].empty()) continue; auto [x, ind] = q[i].top(); if(nw[i] >= x){ ll ch = 1; for(ll j = 1; j <= m; j ++){ if(nw[j] < v[ind][j]){ ch = 0; break; } } if(ch){ f = 1; vis[ind] = 1; cv ++; q[i].pop(); for(ll j = 1; j <= m; j ++){ nw[j] += s[ind][j]; } } } } } cout << cv << '\n'; } signed main() { ll tm = clock(); cin.tie(0)->sync_with_stdio(0); ll t = 1; // cin >> t; for(ll tt = 1; tt <= t; tt ++) { _(tt); } cerr << "\n\033[1;31mTime: \033[1;30m" \ << (double)(clock()-tm)/1000000 << "\033[1;32m seconds\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...