Submission #423284

#TimeUsernameProblemLanguageResultExecution timeMemory
423284haxormanGarage (IOI09_garage)C++14
40 / 100
3 ms332 KiB
#include <bits/stdc++.h> using namespace std; const int mxN = 107; const int mxM = 2007; bool arr[mxN]; int r[mxN], w[mxM], pos[mxM]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i) { cin >> r[i]; } for (int i = 1; i <= m; ++i) { cin >> w[i]; } long long ans = 0; queue<int> q; for (int iter = 1; iter <= 2 * m; ++iter) { int car; cin >> car; if (car < 0) { car = -car; arr[pos[car]] = false; for (int i = 1; i <= n && q.size(); ++i) { if (!arr[i]) { cout << q.front() << ' ' << i << "\n"; arr[i] = true; ans += r[i] * w[q.front()]; pos[q.front()] = i; q.pop(); } } } else { q.push(car); for (int i = 1; i <= n && q.size(); ++i) { if (!arr[i]) { //cout << q.front() << ' ' << i << "\n"; arr[i] = true; ans += r[i] * w[q.front()]; pos[q.front()] = i; q.pop(); } } } } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...