제출 #1173587

#제출 시각아이디문제언어결과실행 시간메모리
1173587Zero_OPTopical (NOI23_topical)C++20
100 / 100
369 ms123528 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i, l, r) for(int i = (l); i < (r); ++i) #define ROF(i, r, l) for(int i = (r)-1; i >= (l); --i) #define mp make_pair #define mt make_tuple #define ff first #define ss second #define all(v) begin(v), end(v) #define rall(v) rbegin(v), rend(v) #define sz(v) (int)v.size() #define pb push_back #define eb emplace_back #define compact(v) v.erase(unique(all(v)), end(v)) #define dbg(x) "[" #x " = " << (x) << "]" template<typename T> bool minimize(T& a, const T& b){ if(a > b) return a = b, true; return false; } template<typename T> bool maximize(T& a, const T& b){ if(a < b) return a = b, true; return false; } typedef long long ll; using db = double; using ull = unsigned long long; using pi = pair<int, int>; using pl = pair<ll, ll>; using pd = pair<db, db>; using vi = vector<int>; using vl = vector<ll>; using vc = vector<char>; using vd = vector<db>; using vb = vector<bool>; using vpi = vector<pi>; using vpl = vector<pl>; void setIO(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef LOCAL freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); #endif } int main(){ setIO(); int N, K; cin >> N >> K; vector<vi> require(N, vi(K)); FOR(i, 0, N) FOR(j, 0, K) cin >> require[i][j]; vector<vi> profit(N, vi(K)); FOR(i, 0, N) FOR(j, 0, K) cin >> profit[i][j]; vector<vpi> onlines(K); vi cnt(N); stack<int> delay; FOR(i, 0, N){ FOR(j, 0, K){ if(require[i][j] == 0){ ++cnt[i]; if(cnt[i] == K) delay.push(i); continue; } onlines[j].pb(mp(require[i][j], i)); } } FOR(i, 0, K) sort(rall(onlines[i])); vi current(K, 0); int n_visited = 0; while(!delay.empty()){ ++n_visited; int pos = delay.top(); delay.pop(); FOR(i, 0, K){ current[i] += profit[pos][i]; while(!onlines[i].empty() && onlines[i].back().ff <= current[i]){ int c = onlines[i].back().ss; ++cnt[c]; if(cnt[c] == K) delay.push(c); onlines[i].pop_back(); } } } cout << n_visited << '\n'; 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...