Submission #287380

#TimeUsernameProblemLanguageResultExecution timeMemory
287380NamnamseoGarage (IOI09_garage)C++17
100 / 100
2 ms384 KiB
#include <cstdio> #include <cstdlib> int sc[2010]; int ww[2010]; int place[2010]; int who [2010]; int n,m; int queue[2010]; int h,t; int main() { int income=0; scanf("%d%d",&n,&m); for(int i=1; i<=n; ++i) scanf("%d",sc+i); for(int i=1; i<=m; ++i) scanf("%d",ww+i); int a; int filled=0; for(int _=1; _<=2*m; ++_){ scanf("%d",&a); if(a>0){ queue[h++]=a; } else { a=-a; who[place[a]]=0; place[a]=0; --filled; } while(filled<n && t<h){ int i; for(i=1; i<=n; ++i){ if(who[i]==0) break; } who[i]=queue[t]; place[queue[t]]=i; income += sc[i]*ww[who[i]]; ++filled; ++t; } } printf("%d\n",income); return 0; }

Compilation message (stderr)

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