제출 #348796

#제출 시각아이디문제언어결과실행 시간메모리
348796MefarnisGarage (IOI09_garage)C++14
100 / 100
1 ms384 KiB
#include <bits/stdc++.h> #define maxn 101 #define maxm 2001 using namespace std; int n,m,ans; int r[maxn]; int w[maxm]; int slot[maxm]; bool mark[maxn]; queue<int> Q; int main() { scanf("%d%d",&n,&m); for( int i = 1 ; i <= n ; i++ ) scanf("%d",&r[i]); for( int i = 1 ; i <= m ; i++ ) scanf("%d",&w[i]); for( int q = 0 , id ; q < 2*m ; q++ ) { scanf("%d",&id); if(id > 0) { int idx = -1; for( int i = 1 ; i <= n ; i++ ) if(!mark[i]) { idx = i; slot[id] = i; mark[i] = true; ans += r[i] * w[id]; break; } if(idx == -1) Q.push(id); } else { id = -id; if(Q.empty()) mark[slot[id]] = false; else { int car = Q.front(); Q.pop(); ans += r[slot[id]] * w[car]; slot[car] = slot[id]; } } } printf("%d\n",ans); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

garage.cpp: In function 'int main()':
garage.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |  scanf("%d%d",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~
garage.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |   scanf("%d",&r[i]);
      |   ~~~~~^~~~~~~~~~~~
garage.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |   scanf("%d",&w[i]);
      |   ~~~~~^~~~~~~~~~~~
garage.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |   scanf("%d",&id);
      |   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...