-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11338.cpp
More file actions
40 lines (32 loc) · 777 Bytes
/
Copy path11338.cpp
File metadata and controls
40 lines (32 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<iostream>
#include<queue>
#include<stack>
#include<string>
using namespace std;
int main(){
cin.tie(NULL);
ios_base::sync_with_stdio(false);
int T, Q, K;
cin >> T;
for(int i=0; i<T; i++){
priority_queue<int, vector<int>, greater<int>> pq;
int sum = 0;
cin >> Q >> K;
for(int j=0; j<Q; j++){
string s;
cin >> s;
if(s == "insert"){
int n;
cin >> n;
sum ^= n;
pq.push(n);
if(pq.size() == K+1){
sum ^= pq.top();
pq.pop();
}
}else if(s == "print"){
cout << sum << '\n';
}
}
}
}