Submission #114321

#TimeUsernameProblemLanguageResultExecution timeMemory
114321MetBGarage (IOI09_garage)C++14
100 / 100
3 ms512 KiB
#include <iostream> #include <cstdlib> #include <string> #include <set> #include <stdio.h> #include <map> #include <algorithm> #include <bitset> #include <queue> #include <math.h> #include <stack> #include <vector> #include <string.h> typedef long long ll; const ll MOD = 1e9 + 7, INF = 1e18; using namespace std; ll n, k, a[1000000], m, off[1000000]; vector <ll> v; ll u[100], s[100], w[5000], p[5000], ans; queue <ll> waiting; int main () { cin >> n >> m; for (ll i = 0; i < n; i++) scanf ("%lld", &s[i]); for (ll i = 0; i < m; i++) scanf ("%lld", &w[i]); for (ll i = 0; i < 2 * m; i++) { ll t; scanf ("%lld", &t); if (t >= 0) { t--; bool b = false; for (ll j = 0; j < n; j++) { if (!u[j]) { p[t] = j; ans += s[j] * w[t]; u[j] = 1; b = true; break; } } if (!b) waiting.push (t); } else { t = abs (t) - 1; off[t] = 1; u[p[t]] = 0; while (!waiting.empty () && off[waiting.front ()]) waiting.pop (); if (!waiting.empty ()) { u[p[t]] = 1; p[waiting.front ()] = p[t]; ans += s[p[t]] * w[waiting.front ()]; waiting.pop (); } } } cout << ans; }

Compilation message (stderr)

garage.cpp: In function 'int main()':
garage.cpp:34:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%lld", &s[i]);
   ~~~~~~^~~~~~~~~~~~~~~
garage.cpp:37:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%lld", &w[i]);
   ~~~~~~^~~~~~~~~~~~~~~
garage.cpp:43:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%lld", &t);
   ~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...