Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: august

Problemset: Maximum Adjacent

Language: cpp

Time: 0.002 second

Submitted On: 2026-03-22 15:20:02

#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    string s;

    vector<int> a;
    while (cin>> s) {
        //cout<< s<< ' ';
        if (s.size() == 1 && (s < "0" || s > "9")) break;
        int n1 = stoi(s);

        a.push_back(n1);
    }
    //cout<< '\n';
    //for (auto &x : a) cout<< x<< ' ';
    //cout<< '\n';

    int n=a.size();
    if (a[0] > a[1]) cout<< a[0]<< ' ';
    for (int i=1; i<n-1; i++) if (a[i] > a[i-1] && a[i] > a[i+1]) cout<< a[i]<< ' ';
    if (n >= 2 && a[n-1] > a[n-2]) cout<< a[n-1];
}