You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
603 B
30 lines
603 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
queue<int> q;
|
|
int n;
|
|
cin >> n;
|
|
for (int i = 0; i < n; ++i) {
|
|
string cmd;
|
|
int num;
|
|
cin >> cmd >> num;
|
|
if (cmd == "push")q.push(num);
|
|
else if (cmd == "pop") {
|
|
for (int j = 0; j < num; ++j) {
|
|
int temp = q.front();
|
|
q.pop();
|
|
q.push(temp);
|
|
}
|
|
}
|
|
}
|
|
int p;
|
|
cin >> p;
|
|
for (int i = 0; i < p - 1; ++i) {
|
|
q.pop();
|
|
}
|
|
cout << q.front() << endl;
|
|
return 0;
|
|
}
|