답안 #717705

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
717705 2023-04-02T11:06:16 Z AndrijaM Garage (IOI09_garage) C++14
40 / 100
3 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int ans=0;
    int n,m;
    cin>>n>>m;
    int cpp[n];
    map<int,int>l;
    bool vis[n];
    for(int i=0;i<n;i++)
    {
        cin>>cpp[i];
        vis[i]=false;
    }
    int mass[m];
    for(int i=0;i<m;i++)
    {
        cin>>mass[i];
    }
    int idx;
    queue<int>Q;
    for(int i=0;i<2*m;i++)
    {
        cin>>idx;
        if(idx>0)
        {
            bool ok=false;
            for(int pos=0;pos<n;pos++)
            {
                if(vis[pos]==false)
                {
                    ans+=cpp[pos]*mass[idx-1];
                    l[idx]=pos;
                    vis[pos]=true;
                    ok=true;
                    break;
                }
            }
            if(!ok)
            {
                Q.push(idx);
            }
        }
        else
        {
            idx*=(-1);
            if(Q.size()>0)
            {
                ans+=cpp[l[idx]]*mass[Q.front()-1];
                Q.pop();
            }
            else
            {
                vis[l[idx]]=false;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 304 KB Output isn't correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Correct 1 ms 300 KB Output is correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Correct 1 ms 212 KB Output is correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Correct 1 ms 212 KB Output is correct
10 Incorrect 1 ms 212 KB Output isn't correct
11 Correct 1 ms 212 KB Output is correct
12 Incorrect 1 ms 212 KB Output isn't correct
13 Correct 1 ms 304 KB Output is correct
14 Incorrect 1 ms 340 KB Output isn't correct
15 Correct 2 ms 340 KB Output is correct
16 Incorrect 2 ms 308 KB Output isn't correct
17 Incorrect 2 ms 340 KB Output isn't correct
18 Incorrect 3 ms 340 KB Output isn't correct
19 Incorrect 2 ms 340 KB Output isn't correct
20 Incorrect 3 ms 340 KB Output isn't correct