-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbowling.cpp
More file actions
36 lines (30 loc) · 710 Bytes
/
Copy pathbowling.cpp
File metadata and controls
36 lines (30 loc) · 710 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
#include <iostream>
#include <sstream>
#include <string>
#include <cctype>
#include <set>
using namespace std;
int main(){
multiset <int> shoes;
string buffer, token;
while(getline(cin, buffer)){
stringstream ss(buffer);
ss >> token;
//add shoe
if(token == "ADD"){
ss >> token;
shoes.insert(stoi(token));
}
//request shoe
else{
ss >> token;
auto it = shoes.lower_bound(stoi(token));
if(it == shoes.end())
cout << "impossible" << endl;
else{
cout << *it << endl;
shoes.erase(it);
}
}
}
}