답안 #293949

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
293949 2020-09-08T14:01:19 Z kshitij_sodani Garage (IOI09_garage) C++14
100 / 100
2 ms 416 KB
#include <bits/stdc++.h>
using namespace std;
#define a first
#define b second
#define pb push_back

typedef long long llo;


int n,m;
int it[101];
int aa[2001];
int pp[2001];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	queue<int> ss;
	cin>>n>>m;
	set<int> cur;
	for(int i=0;i<n;i++){
		cur.insert(i);
	}
	for(int i=0;i<n;i++){
		cin>>it[i];
	}
	for(int i=0;i<m;i++){
		cin>>aa[i];
	}
	int ans=0;
	for(int i=0;i<2*m;i++){
		int ind;
		cin>>ind;
		if(ind<0){
			cur.insert(pp[-ind]);
		}
		else{
			ss.push(ind);
		}
		while(cur.size() and ss.size()){
			int x=ss.front();
			ss.pop();
			int y=*(cur.begin());
			cur.erase(y);
			ans+=aa[x-1]*it[y];
			pp[x]=y;
		}
	}
	cout<<ans<<endl;



	


	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 2 ms 416 KB Output is correct