답안 #766913

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
766913 2023-06-26T08:54:45 Z Gabi88 Garage (IOI09_garage) C++14
100 / 100
1 ms 340 KB
#include<bits/stdc++.h>/
using namespace std;

#define LL long long

set<int> s;
queue<int> q;
LL n, m, rj = 0, val[108], tez[2009], pos[2009], tmp;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m;
	for(int i=1; i <= n; i++){ s.insert(i); cin >> val[i]; }
	for(int i=1; i <= m; i++) cin >> tez[i];
	for(int i=0; i < m*2; i++){
		cin >> tmp;
		if (tmp > 0) q.push(tmp);
		else s.insert(pos[-tmp]);
		while (s.size() > 0 and q.size() > 0){ 
			rj += tez[q.front()]*val[*s.begin()];
			pos[q.front()] = *s.begin(); 
			q.pop(); 
			s.erase(s.begin()); 
		}
	}
	cout << rj; return 0;
}

Compilation message

garage.cpp:1:24: warning: extra tokens at end of #include directive
    1 | #include<bits/stdc++.h>/
      |                        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 328 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 340 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct