# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
623440 | neki | Garage (IOI09_garage) | C++14 | 2 ms | 440 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define vc vector
using namespace std;
int main() {
ll n, m;cin >> n >> m;
vc<ll> rate(n+1);
for(ll i=1;i<=n;++i) cin>> rate[i];
vc<ll> w(m+1);
for(ll i=1;i<=m;++i) cin >>w[i];
ll ans=0;
queue<ll> q;
set<ll> prosti; for(ll i=1;i<=n;++i) prosti.insert(i);
vc<ll> plac(m+1);
for(ll i=1;i<=2 * m;++i){
ll t;cin >> t;
if(t>0) q.push(t);
if(t<0) prosti.insert(plac[-t]);
while(prosti.size() and q.size()){
ll u=q.front();q.pop();
plac[u]=*prosti.begin();prosti.erase(prosti.begin());
ans+=rate[plac[u]] * w[u];
}
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |