Submission #230017

#TimeUsernameProblemLanguageResultExecution timeMemory
230017CaroLindaGarage (IOI09_garage)C++14
100 / 100
6 ms384 KiB
#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[MAXM] ; int parked[MAXM] ; set<int> s ; int main() { scanf("%d %d", &N , &M ) ; lp(i,1,N+1) scanf("%d", &rate[i]) , s.insert(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) { idx *= -1 ; ans += rate[ parked[idx] ] * weight[idx] ; s.insert( parked[idx] ) ; } else fila.pb(idx) ; while( ini < fila.size() && s.size() > 0 ) { idx = fila[ini] ; parked[ fila[ini] ] = *s.begin() ; s.erase( s.begin() ) ; ini ++ ; } } printf("%d\n" , ans ) ; }

Compilation message (stderr)

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:49:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while( ini < fila.size() && s.size() > 0 )
                ~~~~^~~~~~~~~~~~~
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:39: 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]) , s.insert(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 ) ;
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...