Submission #311619

#TimeUsernameProblemLanguageResultExecution timeMemory
311619ipaljakGarage (IOI09_garage)C++14
100 / 100
2 ms384 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 105; const int MAXM = 2010; int n, m; int r[MAXN], w[MAXM], park[MAXM]; set<int> sp; int main(void) { scanf("%d%d", &n, &m); for (int i = 0; i < n; ++i) scanf("%d", &r[i]); for (int i = 0; i < m; ++i) scanf("%d", &w[i]); for (int i = 0; i < n; ++i) sp.insert(i); queue<int> q; int sol = 0; for (int i = 0; i < 2 * m; ++i) { int x; scanf("%d", &x); if (x > 0) { --x; if (sp.empty()) { q.push(x); continue; } sol += r[*sp.begin()] * w[x]; park[x] = *sp.begin(); sp.erase(sp.begin()); } else { x = abs(x); --x; sp.insert(park[x]); if (!q.empty()) { int x = q.front(); q.pop(); sol += r[*sp.begin()] * w[x]; park[x] = *sp.begin(); sp.erase(sp.begin()); } } } printf("%d\n", sol); return 0; }

Compilation message (stderr)

garage.cpp: In function 'int main()':
garage.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |   scanf("%d%d", &n, &m);
      |   ~~~~~^~~~~~~~~~~~~~~~
garage.cpp:15:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |   for (int i = 0; i < n; ++i) scanf("%d", &r[i]);
      |                               ~~~~~^~~~~~~~~~~~~
garage.cpp:16:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |   for (int i = 0; i < m; ++i) scanf("%d", &w[i]);
      |                               ~~~~~^~~~~~~~~~~~~
garage.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |     scanf("%d", &x);
      |     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...