답안 #53450

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
53450 2018-06-30T04:44:15 Z 김세빈(#1419) Garage (IOI09_garage) C++11
100 / 100
4 ms 736 KB
#include <bits/stdc++.h>

using namespace std;

int C[111], W[2020], Q[2020], P[2020];
bool K[111];
int n,m,f,r,ans;

int main()
{
	int i,j,a;
	
	scanf("%d%d",&n,&m);
	
	for(i=0;i<n;i++){
		scanf("%d",C+i);
	}
	
	for(i=0;i<m;i++){
		scanf("%d",W+i);
	}
	
	for(i=0;i<m+m;i++){
		scanf("%d",&a);
		if(a > 0){
			a --;
			Q[++f] = a;
		}
		else{
			a = -a-1;
			K[P[a]] = 0;
		}
		
		for(;r<f;r++){
			a = Q[r+1];
			for(j=0;j<n;j++) if(K[j] == 0) break;
			if(j >= n) break;
			ans += C[j] * W[a];
			P[a] = j; K[j] = 1;	
		}
	}
	
	printf("%d\n",ans);
	
	return 0;
}

Compilation message

garage.cpp: In function 'int main()':
garage.cpp:13: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:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",C+i);
   ~~~~~^~~~~~~~~~
garage.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",W+i);
   ~~~~~^~~~~~~~~~
garage.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a);
   ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 2 ms 508 KB Output is correct
7 Correct 2 ms 524 KB Output is correct
8 Correct 2 ms 524 KB Output is correct
9 Correct 2 ms 556 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 2 ms 732 KB Output is correct
12 Correct 2 ms 732 KB Output is correct
13 Correct 2 ms 732 KB Output is correct
14 Correct 2 ms 732 KB Output is correct
15 Correct 2 ms 732 KB Output is correct
16 Correct 3 ms 732 KB Output is correct
17 Correct 3 ms 732 KB Output is correct
18 Correct 3 ms 732 KB Output is correct
19 Correct 4 ms 732 KB Output is correct
20 Correct 3 ms 736 KB Output is correct