# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
718789 | NintsiChkhaidze | Garage (IOI09_garage) | C++17 | 1 ms | 376 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
#define int ll
using namespace std;
const int N = 2e3 + 5;
int val[N],w[N],p[N];
queue <int> q;
set <int> st;
signed main() {
ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
int n,m;
cin>>n>>m;
for (int i=1;i<=n;i++){
st.insert(i);
cin>>val[i];
}
for (int i=1;i<=m;i++)
cin>>w[i];
int ans=0;
for (int i= 1;i<=2*m;i++){
int x;
cin>>x;
if(x > 0){
q.push(x);
}else{
st.insert(p[-x]);
}
while (st.size() && q.size()){
int x = q.front(),id = *st.begin();
q.pop();
p[x] = id;
ans += val[id] * w[x];
st.erase(st.begin());
}
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |