답안 #980844

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
980844 2024-05-12T13:39:40 Z LOLOLO Garage (IOI09_garage) C++14
100 / 100
2 ms 456 KB
#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

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]
   10 |  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]
   12 |   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]
   14 |   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]
   18 |   int t; scanf("%d", &t);
      |          ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 444 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 440 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 456 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 2 ms 452 KB Output is correct