Submission #1094829

#TimeUsernameProblemLanguageResultExecution timeMemory
1094829salmonGarage (IOI09_garage)C++14
100 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; int N; int M; int R[110]; set<int> sat; int inv[2110]; int tim[110]; int W[2100]; int x; queue<int> q; int main(){ scanf(" %d",&N); scanf(" %d",&M); for(int i = 0; i < N; i++){ scanf(" %d",&R[i]); sat.insert(i); } for(int i = 1; i <= M; i++){ inv[i] = -1; scanf(" %d",&W[i]); } long long int ans = 0; for(int i = 0; i < M * 2; i ++){ scanf(" %d",&x); if(x < 0){ x = -x; sat.insert(inv[x]); ans += R[inv[x]] * W[x]; if(!q.empty()){ x = q.front(); q.pop(); } else x = -1; } if(x > 0){ if(sat.empty()){ q.push(x); continue; } int l = *sat.begin(); sat.erase(sat.begin()); tim[l] = i; inv[x] = l; } } printf("%lld",ans); }

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",&N);
      |     ~~~~~^~~~~~~~~~
garage.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf(" %d",&M);
      |     ~~~~~^~~~~~~~~~
garage.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         scanf(" %d",&R[i]);
      |         ~~~~~^~~~~~~~~~~~~
garage.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         scanf(" %d",&W[i]);
      |         ~~~~~^~~~~~~~~~~~~
garage.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         scanf(" %d",&x);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...