Submission #870140

#TimeUsernameProblemLanguageResultExecution timeMemory
870140inawahGarage (IOI09_garage)C++14
100 / 100
1 ms600 KiB
#include <cstdio> #include <queue> using namespace std; #define MAXN 105 #define MAXM 2005 int r[MAXN], w[MAXM], p[MAXM]; queue<int> q; bool vis[MAXN]; int main() { int N, M; scanf("%d %d\n", &N, &M); for (int i = 1; i <= N; ++i) { scanf("%d\n", &r[i]); } for (int i = 1; i <= M; ++i) { scanf("%d\n", &w[i]); } int ans = 0; for (int i = 1; i <= 2*M; ++i) { int a; scanf("%d\n", &a); if (a > 0) { int j; for (j = 1; j <= N && vis[j]; ++j); if (j <= N) { vis[j] = true; p[a] = j; } else { q.push(a); } } else { vis[p[-a]] = false; if (!q.empty()) { int f = q.front(); p[f] = p[-a]; vis[p[f]] = true; q.pop(); } ans += w[-a]*r[p[-a]]; } } printf("%d\n", ans); return 0; }

Compilation message (stderr)

garage.cpp: In function 'int main()':
garage.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d %d\n", &N, &M);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
garage.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d\n", &r[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
garage.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d\n", &w[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
garage.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         scanf("%d\n", &a);
      |         ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...