# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
443673 | Belgutei | Garage (IOI09_garage) | C++17 | 4 ms | 460 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
queue<int> q;
ll n,m,cost[105],weight[2005];
bool used[105];
ll ans;
map<ll,ll> mp;
map<ll,ll> :: iterator it;
int main(){
cin>>n>>m;
for(int i=1; i<=n; i++){
cin>>cost[i];
}
for(int i=1; i<=m; i++){
cin>>weight[i];
}
for(int i=1; i<=2*m; i++){
ll num;
cin>>num;
if(num<0){
num=-num;
if(q.size()>0){
ll val=q.front();
q.pop();
ans+=weight[val]*cost[mp[num]];
mp[val]=mp[num];
}
else{
used[mp[num]]=0;
}
continue;
}
bool check=0;
for(int j=1; j<=n; j++){
if(used[j]==0){
used[j]=1;
check=1;
ans+=cost[j]*weight[num];
mp[num]=j;
break;
}
}
if(check==0) q.push(num);
}
cout<<ans<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |