# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
887875 | JakobZorz | Garage (IOI09_garage) | C++17 | 1 ms | 492 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |