Submission #212276

#TimeUsernameProblemLanguageResultExecution timeMemory
212276jk89Garage (IOI09_garage)C++14
100 / 100
7 ms512 KiB
#include <cstdio> #include <vector> #include <algorithm> #include <set> #include <queue> using namespace std; #define f first #define s second const int MAXN = 1e2 + 3; const int MAXM = 2e3 + 3; int c[MAXN]; int w[MAXM]; int msc[MAXM]; set<int> q; queue<int> kol; int main() { int n, m, x; int wyn = 0; scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) { scanf("%d", &c[i]); q.insert(i); } for (int i = 1; i <= m; i++) scanf("%d", &w[i]); for (int i = 1; i <= 2 * m; i++) { scanf("%d", &x); if (x > 0) { if (q.empty()) kol.push(x); else { wyn += w[x] * c[*q.begin()]; msc[x] = *q.begin(); q.erase(q.begin()); } } else { x = -x; q.insert(msc[x]); if (!kol.empty()) { q.erase(q.begin()); wyn += w[kol.front()] * c[msc[x]]; msc[kol.front()] = msc[x]; kol.pop(); } } } printf("%d", wyn); return 0; }

Compilation message (stderr)

garage.cpp: In function 'int main()':
garage.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
garage.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &c[i]);
         ~~~~~^~~~~~~~~~~~~
garage.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         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]
         scanf("%d", &x);
         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...