답안 #228589

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
228589 2020-05-01T17:42:53 Z s_avila_g Garage (IOI09_garage) C++14
5 / 100
6 ms 512 KB
#include <bits/stdc++.h>
using namespace std;
queue<long long > col;
map<long long ,long long > mp;

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    long long  n,m;
    cin>>n>>m;
    vector<long long > parks(n+1);
    vector<long long > cars(n+1);
    for(long long  i = 1 ; i <= n; i++)cin>>parks[i];
    for(long long  i = 1 ; i <= m; i++)cin>>cars[i];
    long long  vis[n+1];
    memset(vis,0,sizeof vis);
    long long  ans = 0;
    for(long long  i = 0 ; i < (2*m); i++){
        long long  x;
        cin>>x;
        bool libre = false;
        if(x > 0){
            long long  pos;
            for(long long  j = 1; j <= n; j++){
                if(vis[j] == 0){
                    libre = true;
                    pos = j;
                    break;
                }
            }
            if(!libre){
                col.push(x);
            }else{
                mp[x] = pos;
                ans += cars[x] * parks[pos];
                vis[pos] = 1;
            }
        }else{
            vis[mp[abs(x)]] = 0;
            if(!col.empty()){
                long long nxt = col.front();
                vis[mp[abs(x)]] = 1;
                mp[nxt] = mp[abs(x)];
                col.pop();
                ans += cars[nxt] * parks[mp[abs(x)]];
            }
            mp[abs(x)] = -1;
        }
    }
    cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Correct 5 ms 256 KB Output is correct
4 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 5 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 5 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 5 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)