Submission #1286328

#TimeUsernameProblemLanguageResultExecution timeMemory
1286328BlockOGGarage (IOI09_garage)C++20
100 / 100
2 ms584 KiB
#include <bits/stdc++.h> // mrrrow meeow :3 // go play vivid/stasis now! https://vividstasis.gay #define fo(i, a, b) for (auto i = (a); i < (b); i++) #define of(i, a, b) for (auto i = (b); i-- > (a);) #define f first #define s second #define pb push_back #define lb lower_bound #define ub upper_bound #define be(a) a.begin(), a.end() using namespace std; int ____init = [] { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); return 0; }(); int r[100], u[100]; int w[2000], cm[2000]; int main() { int n, m; cin >> n >> m; fo(i, 0, n) cin >> r[i]; fo(i, 0, m) cin >> w[i]; int used = 0; int res = 0; queue<int> cars; fo(_, 0, 2*m) { int c; cin >> c; if (c > 0) { c--; cars.push(c); } else { c = -c - 1; res += r[cm[c]] * w[c]; u[cm[c]] = false; used--; } while (cars.size() && used < n) { fo(i, 0, n) { if (!u[i]) { cm[cars.front()] = i, cars.pop(), u[i] = true, used++; break; } } } } cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...