Submission #1193371

#TimeUsernameProblemLanguageResultExecution timeMemory
1193371jecklexGarage (IOI09_garage)C++20
60 / 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); // weight*garage int n,m; cin >> n >> m; int p_rate[n]; int c_weight[m]; for (int i = 0; i < n; ++i) { cin >> p_rate[i]; } for (int i = 0; i < m; ++i) { cin >> c_weight[i]; } int p; int dollar = 0; int garage[n]; bool f; queue<int> q; for (int i = 0; i < n; ++i) { garage[i] = 0; } int v; 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; //dollar += p_rate[j]*c_weight[p-1]; 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) { f = true; } else { garage[j] = q.front(); q.pop(); } break; } } } if (!f) { q.push(abs(p)); } //cout << " " << dollar << endl; } cout << dollar; }
#Verdict Execution timeMemoryGrader output
Fetching results...