Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stack>
- using namespace std;
- int main() {
- int N, S, X, n, minNum = 2147483647;
- cin >> N >> S >> X;
- stack<int> numbers;
- for (int i = 0; i < N; i++) {
- cin >> n;
- numbers.push(n);
- }
- for (int i = 0; i < S; i++) {
- numbers.pop();
- if (numbers.empty()) {
- cout << '0' << endl;
- return 0;
- }
- }
- while (!numbers.empty()) {
- if (numbers.top() == X) {
- cout << "true" << endl;
- return 0;
- }
- else if (numbers.top() < minNum) {
- minNum = numbers.top();
- }
- numbers.pop();
- }
- cout << minNum << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement