Submission #545589

#TimeUsernameProblemLanguageResultExecution timeMemory
545589pere_gilGarage (IOI09_garage)C++17
100 / 100
1 ms340 KiB
#include "bits/stdc++.h" using namespace std; int main(){ int n,m; scanf("%d %d",&n,&m); vector<int> r(n+1); for(int i=1;i<=n;i++) scanf("%d",&r[i]); vector<int> h(m+1); for(int i=1;i<=m;i++) scanf("%d",&h[i]); queue<int> car; priority_queue<int,vector<int>,greater<int>> parking; for(int i=n;i>0;i--) parking.push(i); vector<int> v(m+1); m*=2; long long res=0; while(m--){ int act; scanf("%d",&act); if(act>0){ if(parking.empty()) car.push(act); else{ v[act]=parking.top(); parking.pop(); res+=h[act]*r[v[act]]; } } else{ parking.push(v[-act]); if(!car.empty()){ act=car.front(); car.pop(); v[act]=parking.top(); parking.pop(); res+=h[act]*r[v[act]]; } } } printf("%lld\n",res); return 0; }

Compilation message (stderr)

garage.cpp: In function 'int main()':
garage.cpp:5:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |  int n,m; scanf("%d %d",&n,&m);
      |           ~~~~~^~~~~~~~~~~~~~~
garage.cpp:7:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  for(int i=1;i<=n;i++) scanf("%d",&r[i]);
      |                        ~~~~~^~~~~~~~~~~~
garage.cpp:9:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  for(int i=1;i<=m;i++) scanf("%d",&h[i]);
      |                        ~~~~~^~~~~~~~~~~~
garage.cpp:18:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   int act; scanf("%d",&act);
      |            ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...