| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1031674 | ezzzay | Garage (IOI09_garage) | C++14 | 1 ms | 444 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define int long long
const int N=3e5+5;
int pr[N];
int w[N];
int pos[N];
int arr[N];
signed main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>pr[i];
}
for(int i=1;i<=m;i++){
cin>>w[i];
}
set<int>st,ts;
for(int i=1;i<=n;i++){
st.insert(i);
}
queue<int>q;
int ans=0;
for(int i=0;i<2*m;i++){
int h;
cin>>h;
if(h>0){
q.push(h);
}
else{
h*=-1;
st.insert(pos[h]);
pos[h]=0;
}
while(!q.empty() and st.size()>0){
int h=q.front();
q.pop();
int x=*st.begin();
st.erase(st.begin());
ans+= w[h]*pr[x];
pos[h]=x;
}
}
cout<<ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
