답안 #495434

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
495434 2021-12-18T15:54:27 Z ToroTN Garage (IOI09_garage) C++14
100 / 100
2 ms 336 KB
#include<bits/stdc++.h>
using namespace std;
int n,m,hsh[105],w[2005],r[105],car,cnt=0,u,type;
queue<int> q;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&r[i]);
    }
    for(int i=1;i<=m;i++)
    {
        scanf("%d",&w[i]);
    }
    for(int i=1;i<=2*m;i++)
    {
        scanf("%d",&car);
        if(car>0)
        {
            q.push(car);
        }else
        {
            for(int j=1;j<=n;j++)
            {
                if(hsh[j]==-car)
                {
                    hsh[j]=0;
                }
            }
        }
        while(!q.empty())
        {
            u=q.front();
            type=-1;
            for(int j=1;j<=n;j++)
            {
                if(hsh[j]==0)
                {
                    type=0;
                    hsh[j]=u;
                    cnt+=r[j]*w[u];
                    break;
                }
            }
            if(type==-1)
            {
                break;
            }
            q.pop();
        }
        //printf("%d\n",cnt);
    }
    printf("%d\n",cnt);
}

Compilation message

garage.cpp: In function 'int main()':
garage.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
garage.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         scanf("%d",&r[i]);
      |         ~~~~~^~~~~~~~~~~~
garage.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%d",&w[i]);
      |         ~~~~~^~~~~~~~~~~~
garage.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d",&car);
      |         ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 2 ms 208 KB Output is correct
18 Correct 2 ms 304 KB Output is correct
19 Correct 2 ms 336 KB Output is correct
20 Correct 1 ms 208 KB Output is correct