답안 #623440

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
623440 2022-08-05T15:37:22 Z neki Garage (IOI09_garage) C++14
100 / 100
2 ms 440 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 440 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct