# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
230016 | CaroLinda | Garage (IOI09_garage) | C++14 | 10 ms | 512 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |