Submission #372556

#TimeUsernameProblemLanguageResultExecution timeMemory
372556Christopher_RdzGarage (IOI09_garage)C++17
50 / 100
2 ms364 KiB
#include <iostream> #include <queue> using namespace std; int espacio[102]; int carros[2002]; int cubeta[102]; queue<int> cola; int main(){ ios_base::sync_with_stdio(0); int n, m, aux; 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 i = 1; i <= n; i++){ if (cubeta[i] == 0){ cubeta[i] = aux; lugar = i; break; } } if (lugar != 0){ tot += espacio[lugar] * carros[aux]; }else{ cola.push(aux); } }else{ int pos; for (int i = 1; i <= n; i++){ if (cubeta[i] == abs(aux)){ cubeta[i] = 0; pos = i; break; } } if (cola.size() >= 1){ int f = cola.front(); cola.pop(); tot += espacio[pos] * carros[f]; } } } cout << tot; }

Compilation message (stderr)

garage.cpp: In function 'int main()':
garage.cpp:50:27: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   50 |         tot += espacio[pos] * carros[f];
      |                ~~~~~~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...