답안 #545583

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
545583 2022-04-04T23:15:10 Z pere_gil Garage (IOI09_garage) C++17
30 / 100
1 ms 340 KB
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main(){
	ll n,m; scanf("%lld %lld",&n,&m);
	vector<ll> r(n+1);
	for(ll i=1;i<=n;i++) scanf("%lld",&r[i]);
	vector<ll> h(m+1);
	for(ll i=1;i<=m;i++) scanf("%lld",&h[i]);

	queue<ll> car;
	stack<ll> place;
	ll res=0;
	for(ll i=n;i>0;i--) place.push(i);
	vector<ll> v(m+1);
	for(ll i=0;i<2*m;i++){
		ll act; scanf("%lld",&act);
		if(act>0){
			if(place.empty()) car.push(act);
			else{
				v[act]=place.top();
				//prllf("putting car %d in %d so + %d * %d -> %d\n",act,place.top(),h[act],r[v[act]],h[act]*r[v[act]]);
				res+=h[act]*r[v[act]];
				place.pop();
			}
		}
		else{
			place.push(v[-act]);
			if(!car.empty()){
				v[car.front()]=place.top();
				//prllf("r putting car %d in %d so + %d * %d -> %d\n",car.front(),place.top(),h[car.front()],r[v[car.front()]],h[car.front()]*r[v[car.front()]]);
				res+=h[car.front()]*r[v[car.front()]];
				place.pop();
				car.pop();
			}
		}
	}
	
	printf("%lld\n",res);
	
	return 0;
}

Compilation message

garage.cpp: In function 'int main()':
garage.cpp:7:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  ll n,m; scanf("%lld %lld",&n,&m);
      |          ~~~~~^~~~~~~~~~~~~~~~~~~
garage.cpp:9:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  for(ll i=1;i<=n;i++) scanf("%lld",&r[i]);
      |                       ~~~~~^~~~~~~~~~~~~~
garage.cpp:11:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  for(ll i=1;i<=m;i++) scanf("%lld",&h[i]);
      |                       ~~~~~^~~~~~~~~~~~~~
garage.cpp:19:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   ll act; scanf("%lld",&act);
      |           ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Correct 0 ms 212 KB Output is correct
11 Incorrect 0 ms 212 KB Output isn't correct
12 Incorrect 1 ms 212 KB Output isn't correct
13 Incorrect 1 ms 212 KB Output isn't correct
14 Incorrect 1 ms 292 KB Output isn't correct
15 Incorrect 1 ms 276 KB Output isn't correct
16 Incorrect 1 ms 212 KB Output isn't correct
17 Incorrect 1 ms 212 KB Output isn't correct
18 Incorrect 1 ms 212 KB Output isn't correct
19 Correct 1 ms 340 KB Output is correct
20 Incorrect 1 ms 212 KB Output isn't correct