# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
869022 | HuyQuang_re_Zero | Garage (IOI09_garage) | C++14 | 2 ms | 4556 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define N 200005
#define II pair <ll,ll>
#define III pair <ll,II>
#define IV pair <vector <int>,vector <int> >
#define fst first
#define snd second
#define BIT(x,i) ((x>>i)&1)
#define Log(x) (31-__builtin_clz((int)x))
#define LogLL(x) (63-__builtin_clzll((ll)x))
#define pi acos(-1)
#define to_radian(x) (x*pi/180.0)
#define to_degree(x) (x*180.0/pi)
using namespace std;
ll n,m,c[N],w[N],i,u,res,ok[N],pos[N];
queue <int> car;
int Find()
{
int i;
for(i=1;i<=n;i++)
if(ok[i]) break;
return i;
}
int main()
{
// freopen("garage.inp","r",stdin);
//freopen("garage.out","w",stdout);
cin>>n>>m;
for(i=1;i<=n;i++) cin>>c[i],ok[i]=1;
for(i=1;i<=m;i++) cin>>w[i];
for(i=1;i<=2*m;i++)
{
cin>>u;
if(u>0) car.push(u); else ok[pos[-u]]=1;
while(car.size()>0)
{
int u=car.front(),k=Find();
if(k>n) break;
pos[u]=k; ok[k]=0;
res+=w[u]*c[k];
car.pop();
}
}
cout<<res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |