제출 #545581

#제출 시각아이디문제언어결과실행 시간메모리
545581pere_gilGarage (IOI09_garage)C++17
30 / 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; stack<int> place; int res=0; for(int i=n;i>0;i--) place.push(i); vector<int> v(m+1); for(int i=0;i<2*m;i++){ int act; scanf("%d",&act); if(act>0){ if(place.empty()) car.push(act); else{ v[act]=place.top(); //printf("putting car %d in %d so + %d * %d -> %d\n",act,place.top(),h[act],r[v[act]],h[act]*r[v[act]]); res+=h[act]*r[v[act]]; place.pop(); } } else{ place.push(v[-act]); if(!car.empty()){ v[car.front()]=place.top(); //printf("r putting car %d in %d so + %d * %d -> %d\n",car.front(),place.top(),h[car.front()],r[v[car.front()]],h[car.front()]*r[v[car.front()]]); res+=h[car.front()]*r[v[car.front()]]; place.pop(); car.pop(); } } } printf("%d\n",res); return 0; }

컴파일 시 표준 에러 (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:17:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   int act; scanf("%d",&act);
      |            ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...