Submission #53451

# Submission time Handle Problem Language Result Execution time Memory
53451 2018-06-30T04:48:51 Z 장홍준(#2017) Garage (IOI09_garage) C++11
0 / 100
152 ms 33668 KB
#include<stdio.h>
#include<queue>
#include<deque>
using namespace std;
priority_queue<int>H; deque<int>Q;
int qr[4141], C[212], W[4141], V[4141];
int main() {
	freopen("input.txt", "r", stdin);
	int i, j, n, m, ans = 0; scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++)H.push(-i), scanf("%d", &C[i]);
	for (i = 1; i <= m; i++)scanf("%d", &V[i]);
	for (i = 0; i < m * 2; i++) {
		int x; scanf("%d", &x);
		if (x > 0) {
			if (H.empty())Q.push_back(x);
			else W[x] = -H.top(), H.pop(), ans += C[W[x]] * V[x];
		}
		else {
			x = -x;
			if(Q.empty()) H.push(-W[x]);
			else {
				int now = Q.front(); Q.pop_front();
				W[now] = W[x]; W[x] = 0; ans += C[W[now]] * V[now];
			}
		}
	}
	printf("%d", ans);
	return 0;
}

Compilation message

garage.cpp: In function 'int main()':
garage.cpp:9:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j, n, m, ans = 0; scanf("%d%d", &n, &m);
         ^
garage.cpp:8:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("input.txt", "r", stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
garage.cpp:9:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int i, j, n, m, ans = 0; scanf("%d%d", &n, &m);
                           ~~~~~^~~~~~~~~~~~~~~~
garage.cpp:10:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i = 1; i <= n; i++)H.push(-i), scanf("%d", &C[i]);
                          ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
garage.cpp:11:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i = 1; i <= m; i++)scanf("%d", &V[i]);
                          ~~~~~^~~~~~~~~~~~~
garage.cpp:13:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int x; scanf("%d", &x);
          ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 137 ms 33340 KB Output isn't correct
2 Incorrect 114 ms 33340 KB Output isn't correct
3 Incorrect 152 ms 33412 KB Output isn't correct
4 Incorrect 142 ms 33412 KB Output isn't correct
5 Incorrect 119 ms 33544 KB Output isn't correct
6 Incorrect 146 ms 33544 KB Output isn't correct
7 Incorrect 126 ms 33544 KB Output isn't correct
8 Incorrect 122 ms 33544 KB Output isn't correct
9 Incorrect 130 ms 33544 KB Output isn't correct
10 Incorrect 116 ms 33544 KB Output isn't correct
11 Incorrect 114 ms 33544 KB Output isn't correct
12 Incorrect 116 ms 33544 KB Output isn't correct
13 Incorrect 118 ms 33544 KB Output isn't correct
14 Incorrect 121 ms 33544 KB Output isn't correct
15 Incorrect 116 ms 33544 KB Output isn't correct
16 Incorrect 116 ms 33544 KB Output isn't correct
17 Incorrect 120 ms 33544 KB Output isn't correct
18 Incorrect 142 ms 33588 KB Output isn't correct
19 Incorrect 125 ms 33636 KB Output isn't correct
20 Incorrect 120 ms 33668 KB Output isn't correct