Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Test

Problemset: Maximum Adjacent

Language: cpp

Time: 0.002 second

Submitted On: 2026-03-17 22:54:55


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

int main(){
    int ck=0;
    vector<int> v;
    int sz=0;
    int x;
    while(cin >> x){
        sz++;
        v.push_back(x);
    }
    if(sz == 0) return 0;

    if(sz == 1){
        cout << v[0];
        return 0;
    }
    if(v[1]<v[0]) cout << v[0] << " ";
    for(int i=1;i<sz-1;i++){
        if(v[i+1]<v[i] && v[i-1]<v[i]){
            cout << v[i] << " ";
        }
    }
    if(v[sz-1]>v[sz-2]) cout << v[sz-1] << " ";

}