답안 #99199

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99199 2019-03-01T15:47:44 Z figter001 Garage (IOI09_garage) C++14
100 / 100
6 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const ll oo = 1e18;
const ll mod = 1e9+7;
const int nax = 110;
const int mx = 2010;

ll r[nax],w[mx],at[mx];

int main(){
	#ifndef ONLINE_JUDGE
		// freopen("input.txt","r",stdin);
	#endif
	int n,m;
	cin>>n>>m;
	set<int> st;
	for(int i=1;i<=n;i++){
		st.insert(i);
		cin>>r[i];
	}
	for(int i=1;i<=m;i++)
		cin>>w[i];
	ll ans = 0;
	queue<int> q;
	for(int i=1;i<=2*m;i++){
		int t;
		cin>>t;
		if(t > 0){
			q.push(t);
		}else{
			t = -t;
			st.insert(at[t]);
		}
		while(q.size() && st.size()){
			t = q.front();
			q.pop();
			at[t] = *st.begin();
			ans += w[t] * r[at[t]];
			st.erase(st.begin());
		}
	}
	cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct