제출 #887875

#제출 시각아이디문제언어결과실행 시간메모리
887875JakobZorzGarage (IOI09_garage)C++17
100 / 100
1 ms492 KiB
#include<iostream> #include<vector> #include<queue> #include<stack> #include<algorithm> #include<limits.h> #include<math.h> #include<map> #include<set> #include<unordered_map> #include<unordered_set> #include<iomanip> #include<cstring> typedef long long ll; typedef unsigned long long ull; typedef long double ld; using namespace std; //const int MOD=1e9+7; //typedef pair<ll,ll>Point; //typedef pair<ll,ll>Line; //#define x first //#define y second void solve(){ int n,m; cin>>n>>m; vector<int>r(n); for(int&i:r) cin>>i; vector<int>w(m); for(int&i:w) cin>>i; vector<int>e(2*m); for(int&i:e) cin>>i; int res=0; vector<int>parked(n,-1); int timer=0; queue<int>q; for(int event:e){ if(event>0){ event--; bool par=false; for(int i=0;i<n;i++){ if(parked[i]==-1){ parked[i]=event; par=true; break; } } if(!par) q.push(event); }else{ event=-event-1; for(int i=0;i<n;i++){ if(parked[i]==event){ parked[i]=-1; res+=r[i]*w[event]; if(q.size()){ parked[i]=q.front(); q.pop(); } } } } timer++; } cout<<res<<"\n"; } int main(){ ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL); //freopen("bank.in","r",stdin);freopen("bank.out","w",stdout); int t=1;//cin>>t; while(t--)solve(); return 0; } /* 3 4 2 3 5 200 100 300 800 3 2 -3 1 4 -4 -2 -1 */
#Verdict Execution timeMemoryGrader output
Fetching results...