Submission #53584

#TimeUsernameProblemLanguageResultExecution timeMemory
53584ho94949Garage (IOI09_garage)C++17
100 / 100
4 ms748 KiB
#include<bits/stdc++.h>
using namespace std;
int N, M;
int R[101010];
int W[101010]; //R*W
int pos[101010];
queue<int> Q;
int main()
{
	scanf("%d%d", &N, &M);
	for(int i=1; i<=N; ++i)
		scanf("%d", R+i);
	for(int i=1; i<=M; ++i)
		scanf("%d", W+i);
	int ans = 0;
	for(int i=0; i<2*M; ++i)
	{
		int t; scanf("%d", &t);
		if(t>0)
			Q.push(t);
		else
		{
			for(int i=1; i<=N; ++i)
				if(pos[i] == -t) pos[i] = 0;
		}
		for(int i=1; i<=N; ++i)
		{
			if(pos[i] == 0 && !Q.empty())
			{
				pos[i] = Q.front(); Q.pop();
				ans += R[i] * W[pos[i]];
			}
		}
	}
	printf("%d\n", ans);
}

Compilation message (stderr)

garage.cpp: In function 'int main()':
garage.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~
garage.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", R+i);
   ~~~~~^~~~~~~~~~~
garage.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", W+i);
   ~~~~~^~~~~~~~~~~
garage.cpp:18:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int t; scanf("%d", &t);
          ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...