Submission #480163

#TimeUsernameProblemLanguageResultExecution timeMemory
480163gg123_peGarage (IOI09_garage)C++17
40 / 100
2 ms332 KiB
#include <bits/stdc++.h> using namespace std; #define f(i,a,b) for(int i = a; i < b; i++) int n, m, x, ans, rate[105], w[2005], place[2005], freee; bool on[105]; int main(){ cin >> n >> m; f(i,1,n+1) cin >> rate[i]; f(i,1,m+1) cin >> w[i]; freee = n; queue <int> q; f(i,0,2*m){ cin >> x; if(x < 0){ on[place[-x]] = 0, freee++; while(!q.empty()){ if(freee == 0) break; int t = q.front(); f(j,1,n+1){ if(!on[j]) { place[x] = j, on[j] = 1, ans += rate[j]*w[t]; break; } } q.pop(), freee--; } continue; } else{ q.push(x); while(!q.empty()){ if(freee == 0) break; int t = q.front(); f(j,1,n+1){ if(!on[j]) { place[x] = j, on[j] = 1, ans += rate[j]*w[t]; break; } } q.pop(), freee--; } } } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...