제출 #1192271

#제출 시각아이디문제언어결과실행 시간메모리
1192271simplemind_31Garage (IOI09_garage)C++20
100 / 100
1 ms328 KiB
#include <bits/stdc++.h> #define ALL(x) x.begin(),x.end() using namespace std; typedef long long ll; int n,m,space[100],weight[2000],used[100],reused[2000],x,sobra; queue<int> entrance; ll sum=0; int main(){ ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin >> n >> m; for(int i=0;i<n;i++){ cin >> space[i]; } for(int i=0;i<m;i++){ cin >> weight[i]; } sobra=n; m*=2; while(m--){ cin >> x; if(x>0){ entrance.push(x-1); }else{ sobra++; used[reused[-x-1]]=false; } while(!entrance.empty()&&sobra){ x=entrance.front(); entrance.pop(); for(int i=0;i<n;i++){ if(!used[i]){ used[i]=true; reused[x]=i; sum+=weight[x]*space[i]; sobra--; break; } } } } cout << sum; }
#Verdict Execution timeMemoryGrader output
Fetching results...