Submission #879051

#TimeUsernameProblemLanguageResultExecution timeMemory
879051kleeGarage (IOI09_garage)C++14
40 / 100
2 ms604 KiB
#include <bits/stdc++.h> using namespace std; vector<int> have(101), where(101); int main() { int n,m; cin >> n >> m; vector<int> price(n+1), weight(m+1); for(int i=1;i<=n;i++) cin >> price[i]; for(int i=1;i<=m;i++) cin >> weight[i]; int ans=0; for(int i=0;i<2*m;i++) { int x; cin >> x; if(x>=0) { for(int j=1;j<=n;j++) { if(have[j] == 0) { have[j] = 1; ans+= (price[j]*weight[x]); // cout << j << 'a' << x << ' ' << price[j] << ' ' << weight[x] << ' ' << price[j]*weight[x] << ' ' << ans << ' ' << '\n'; where[x] = j; break; } } } else { x = abs(x); int a = where[x]; have[a] = 0; } } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...