Submission #121462

# Submission time Handle Problem Language Result Execution time Memory
121462 2019-06-26T14:22:04 Z TadijaSebez Garage (IOI09_garage) C++11
100 / 100
3 ms 384 KB
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
using namespace std;
const int N=2050;
int r[N],w[N],my[N];
set<int> Free;
queue<int> q;
int main()
{
	int n,m,i,sol=0,x;
	scanf("%i %i",&n,&m);
	for(i=1;i<=n;i++) scanf("%i",&r[i]),Free.insert(i);
	for(i=1;i<=m;i++) scanf("%i",&w[i]);
	for(i=1;i<=m*2;i++)
	{
		scanf("%i",&x);
		if(x>0) q.push(x);
		else x=-x,Free.insert(my[x]);
		while(q.size() && Free.size())
		{
			int car=q.front();
			q.pop();
			int space=*Free.begin();
			Free.erase(space);
			my[car]=space;
			sol+=r[space]*w[car];
		}
	}
	printf("%i\n",sol);
	return 0;
}

Compilation message

garage.cpp: In function 'int main()':
garage.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
garage.cpp:15:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1;i<=n;i++) scanf("%i",&r[i]),Free.insert(i);
                    ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
garage.cpp:16:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1;i<=m;i++) scanf("%i",&w[i]);
                    ~~~~~^~~~~~~~~~~~
garage.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%i",&x);
   ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 3 ms 384 KB Output is correct