Submission #733884

# Submission time Handle Problem Language Result Execution time Memory
733884 2023-05-01T11:33:27 Z vjudge1 Garage (IOI09_garage) C++17
100 / 100
2 ms 340 KB
#include<bits/stdc++.h>
using namespace std;

int ans, a[101], b[2001], n, m, x, vis[2001];
set<int> s;
set<int>::iterator it;
vector<int> v;

int main() {
	cin >> n >> m;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		s.insert(i);
	}
	for(int i = 1; i <= m; i++) {
		cin >> b[i];
	}
	for(int i = 1; i <= m * 2; i++) {
		cin >> x;
		if(x < 0) {
			s.insert(vis[x * -1]);
			if(v.size() != 0) {
				it = s.begin();
				vis[v[0]] = *it;
				ans += a[*it] * b[v[0]];
				s.erase(it);
				v.erase(v.begin());
			}
		}
		else {
			v.push_back(x);
			if(s.size() != 0){
				it = s.begin();
				vis[v[0]] = *it;
				ans += a[*it] * b[v[0]];
//				cout << a[*it] << ' ' << b[v[0]] << '\n';
				s.erase(it);
				v.erase(v.begin());
			}
		}
	}
	cout << ans;
	return 0;
}
# Verdict Execution time Memory 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 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 2 ms 324 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 312 KB Output is correct