Submission #495434

#TimeUsernameProblemLanguageResultExecution timeMemory
495434ToroTNGarage (IOI09_garage)C++14
100 / 100
2 ms336 KiB
#include<bits/stdc++.h> using namespace std; int n,m,hsh[105],w[2005],r[105],car,cnt=0,u,type; 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 i=1;i<=2*m;i++) { scanf("%d",&car); if(car>0) { q.push(car); }else { for(int j=1;j<=n;j++) { if(hsh[j]==-car) { hsh[j]=0; } } } while(!q.empty()) { u=q.front(); type=-1; for(int j=1;j<=n;j++) { if(hsh[j]==0) { type=0; hsh[j]=u; cnt+=r[j]*w[u]; break; } } if(type==-1) { break; } q.pop(); } //printf("%d\n",cnt); } printf("%d\n",cnt); }

Compilation message (stderr)

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