Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: C12

Problemset: Maximum Adjacent

Language: cpp

Time: 0.002 second

Submitted On: 2026-03-11 01:51:08

#include <bits/stdc++.h>

using namespace std;

const int mod = 1e9+7;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    string t;

    vector<int> v;
    int n = 0;
    while(1){
        cin >> t;
        
        if((t[0] < '0' || t[0] > '9') && !(t[0] == '-' && t.length() > 1) ) break;
        
        v.push_back(stoi(t));
        n++;
    }

    if(n == 1){
        cout << v[0];
        return 0;
    }

    if(v[0] > v[1]) cout << v[0] << ' ';

    for(int i = 1;i < n-1;i++){
        if(v[i] > v[i-1] && v[i] > v[i+1]) cout << v[i] << ' ';
    }
    
    if(v[n-1] > v[n-2]) cout << v[n-1] << ' ';
    


}