Submission #372557

#TimeUsernameProblemLanguageResultExecution timeMemory
372557Christopher_RdzGarage (IOI09_garage)C++17
45 / 100
1 ms364 KiB
#include <iostream> #include <queue> using namespace std; int espacio[1002]; int carros[2002]; int cubeta[1002]; queue<int> cola; int main(){ ios_base::sync_with_stdio(0); int n, m, aux; long long int tot = 0; cin >> n >> m; for (int i = 1; i <= n; i++){ cin >> espacio[i]; } for (int i = 1; i <= m; i++){ cin >> carros[i]; } int lugar = 1; for (int i = 1; i <= m * 2; i++){ cin >> aux; if (aux > 0){ lugar = 0; for (int j = 1; j <= n; j++){ if (cubeta[j] == 0){ cubeta[j] = aux; lugar = j; break; } } if (lugar != 0){ tot += espacio[lugar] * carros[aux]; }else{ cola.push(aux); } }else{ int x = abs(aux); int pos = 0; for (int j = 1; j <= n; j++){ if (cubeta[j] == x){ cubeta[j] = 0; pos = j; break; } } if (cola.size() >= 1){ int f = cola.front(); cola.pop(); tot += espacio[pos] * carros[f]; } } } cout << tot; }
#Verdict Execution timeMemoryGrader output
Fetching results...