제출 #1193372

#제출 시각아이디문제언어결과실행 시간메모리
1193372jecklexGarage (IOI09_garage)C++20
100 / 100
1 ms328 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; // int64_t MAX_INT = 2147483647; //BASE CASE: n=0? n=1? //OVERFLOW // > 10^9 //(combinatorics) // REPRESENTATION // int == 10e9 // int64_t == 1000000000 int main() { ios::sync_with_stdio(false); cin.tie(nullptr); // freopen(".in", "r", stdin); // freopen(".out", "w", stdout); int n,m; cin >> n >> m; int p_rate[n]; int c_weight[m]; ll garage[n]; for (int i = 0; i < n; ++i) { cin >> p_rate[i]; garage[i] = 0; } for (int i = 0; i < m; ++i) { cin >> c_weight[i]; } int p; int dollar = 0; bool f; queue<int> q; for (int i = 0; i < 2*m; ++i) { cin >> p; f = false; for (int j = 0; j < n; ++j) { if (p > 0) { if (garage[j] == 0) { garage[j] = p; f = true; break; } } else { if (garage[j] == abs(p)) { garage[j] = 0; dollar += p_rate[j]*c_weight[abs(p)-1]; if (q.size() != 0) { garage[j] = q.front(); q.pop(); } f = true; break; } } } if (!f) { q.push(abs(p)); } } cout << dollar; }
#Verdict Execution timeMemoryGrader output
Fetching results...