Submission #71499

#TimeUsernameProblemLanguageResultExecution timeMemory
71499RezwanArefin01Garage (IOI09_garage)C++17
100 / 100
6 ms952 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; int w[2010], r[110], pos[2010], ans; int main(int argc, char const *argv[]) { int n, m; 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]); queue<int> q; priority_queue<int, vector<int>, greater<int> > Q; for(int i = 1; i <= n; i++) Q.push(i); for(m *= 2; m--; ) { int x, y; scanf("%d", &x); if(x < 0) Q.push(pos[-x]); else q.push(x); while(!q.empty() && !Q.empty()) { x = q.front(); q.pop(); y = Q.top(); Q.pop(); ans += w[x] * r[y]; pos[x] = y; } } printf("%d\n", ans); }

Compilation message (stderr)

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