답안 #134411

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
134411 2019-07-22T16:19:55 Z sheismad Garage (IOI09_garage) C++14
20 / 100
3 ms 508 KB
#include <cstdio>
#include <iostream>
#include <queue>

using namespace std;

int const MAXN = 101,MAXM = 2001;
int park[MAXN];

int main() {
	//freopen("input.txt","r",stdin);
	
	int n,m,weight[MAXM],price[MAXN],car;
	long long ans = 0;
	queue<int> q;
	scanf("%d %d\n",&n,&m);
	for (int i=0;i<n;i++) scanf("%d",&price[i]);
	for (int i=0;i<m;i++) scanf("%d",&weight[i]);
	
	int j,mini = 0;
	for (int i=0;i<m*2;i++) {
		scanf("%d",&car);
		j = 0;
		//arrive
		if (car>0) {
			while (park[j] && j<n) j++;
			//there is an empty space
			if (j<n) {
				if (q.empty()) {
					park[j] = car; ans += price[j]*weight[car-1];
				}
				else {
					q.push(car); park[j] = q.front(); ans += price[j]*weight[q.front()-1]; q.pop(); 
				}
			} // there is not
			else q.push(car);
		} //departure
		else {
			car *= -1;
			while (park[j]!=car) j++;
			if (!q.empty()) {
				park[j] = q.front();
				ans += price[j]*weight[q.front()-1];
				q.pop();
			}	
		}
	}
	
	cout << ans;	
	return 0;
}

Compilation message

garage.cpp: In function 'int main()':
garage.cpp:20:8: warning: unused variable 'mini' [-Wunused-variable]
  int j,mini = 0;
        ^~~~
garage.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d\n",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~~~
garage.cpp:17:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=0;i<n;i++) scanf("%d",&price[i]);
                        ~~~~~^~~~~~~~~~~~~~~~
garage.cpp:18:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=0;i<m;i++) scanf("%d",&weight[i]);
                        ~~~~~^~~~~~~~~~~~~~~~~
garage.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&car);
   ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Correct 2 ms 376 KB Output is correct
7 Incorrect 2 ms 256 KB Output isn't correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Incorrect 2 ms 376 KB Output isn't correct
10 Correct 2 ms 256 KB Output is correct
11 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 3 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 3 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 3 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 3 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 3 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Correct 3 ms 376 KB Output is correct
20 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)