답안 #230016

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
230016 2020-05-07T18:26:59 Z CaroLinda Garage (IOI09_garage) C++14
45 / 100
10 ms 512 KB
#include <bits/stdc++.h>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define mkt make_tuple
#define debug printf
#define all(x) x.begin(),x.end()
#define lp(i,a,b) for(int i = a ; i< b ; i++)
#define ss second
#define ff first
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mk make_pair

const int MAXN = 110 ;
const int MAXM = 2010 ;

using namespace std ;

int N , M , ans ;
int rate[MAXN] , weight[MAXN] ;
int parked[MAXM] ;
bool occupied[MAXN] ;

int main()
{
    scanf("%d %d", &N , &M ) ;
    lp(i,1,N+1) scanf("%d", &rate[i]) ;
    lp(i,1,M+1) scanf("%d", &weight[i]) ;

    vector<int> fila ;
    int ini = 0 ;

    for(int i = 1 , idx  ; i <= 2*M ; i++ )
    {
        scanf("%d", &idx ) ;

        if( idx < 0 )
        {
            ans += rate[ parked[-idx] ] * weight[-idx] ;
            if( ini < fila.size() )
                parked[ fila[ini] ] = parked[-idx] , ini ++ ;
            else occupied[ parked[-idx] ] = false ;

            continue ;
        }

        for(int j = 1 ; j <= N ; j++ )
            if(!occupied[j])
            {
                parked[idx] = j ;
                occupied[j] = true ;
                break ;
            }

        if( parked[idx] == 0  ) fila.pb(idx) ;

    }

    printf("%d\n" , ans ) ;

}

Compilation message

garage.cpp:4:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("O3")
 
garage.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("unroll-loops")
 
garage.cpp: In function 'int main()':
garage.cpp:44:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if( ini < fila.size() )
                 ~~~~^~~~~~~~~~~~~
garage.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &N , &M ) ;
     ~~~~~^~~~~~~~~~~~~~~~~~~
garage.cpp:31:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     lp(i,1,N+1) scanf("%d", &rate[i]) ;
                 ~~~~~^~~~~~~~~~~~~~~~
garage.cpp:32:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     lp(i,1,M+1) scanf("%d", &weight[i]) ;
                 ~~~~~^~~~~~~~~~~~~~~~~~
garage.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &idx ) ;
         ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Incorrect 5 ms 384 KB Output isn't correct
11 Runtime error 6 ms 384 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 Incorrect 4 ms 384 KB Output isn't correct
14 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Incorrect 10 ms 384 KB Output isn't correct
16 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Incorrect 5 ms 384 KB Output isn't correct
18 Execution timed out 5 ms 384 KB Time limit exceeded (wall clock)
19 Execution timed out 5 ms 384 KB Time limit exceeded (wall clock)
20 Execution timed out 5 ms 384 KB Time limit exceeded (wall clock)