Submission #467991

#TimeUsernameProblemLanguageResultExecution timeMemory
467991starplatGarage (IOI09_garage)C++14
100 / 100
2 ms332 KiB
#include <bits/stdc++.h> using namespace std; int m,n,ad; long long r[105],w[2005],p,tmp,check; bool a[105]; int aa[105]; queue<int> wa; int main() { cin>>n>>m; p=0;check=0; for (int i=1;i<=n;i++){ scanf("%lld",&r[i]); a[i]=true; aa[i]=0; } for (int i=1;i<=m;i++) scanf("%lld",&w[i]); for (int i=0;i<2*m;i++){ scanf("%d",&ad); if (ad>0) { for (int j=1;j<=n;j++){ if (a[j]==true){ a[j]=false; aa[j]=ad; p+=r[j]*w[ad]; break; } else check++; } if (check==n) wa.push(ad); check=0; } else if (ad<0){ for (int j=1;j<=n;j++){ if (aa[j]==ad*-1){ a[j]=true; aa[j]=0; } } if (wa.empty()) continue; else { for (int j=1;j<=n;j++){ if (a[j]==true){ tmp=wa.front(); wa.pop(); a[j]=false; aa[j]=tmp; p+=r[j]*w[tmp]; break; } } } } } cout<<p<<"\n"; return 0; }

Compilation message (stderr)

garage.cpp: In function 'int main()':
garage.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%lld",&r[i]);
      |         ~~~~~^~~~~~~~~~~~~~
garage.cpp:17:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     for (int i=1;i<=m;i++) scanf("%lld",&w[i]);
      |                            ~~~~~^~~~~~~~~~~~~~
garage.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf("%d",&ad);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...