Submission
Status:
PPPPPPPPPP
Score: 100
User: Nathlol2
Problemset: Maximum Adjacent
Language: cpp
Time: 0.003 second
Submitted On: 2025-03-15 16:17:31
#include <bits/stdc++.h>
using namespace std;
int32_t main(){
ios::sync_with_stdio(false);
cin.tie(0);
string s;
vector<int> a, ans;
while(cin >> s){
stringstream ss(s);
int n;
if(ss >> n && ss.eof()){
a.push_back(n);
}else{
break;
}
}
if(a.size() == 0 || a.size() == 1 || a.size() == 2){
return 0;
}
if(a[0] > a[1]){
ans.push_back(a[0]);
}
for(int i = 1;i<a.size() - 1;i++){
if(a[i] > a[i - 1] && a[i] > a[i + 1]){
ans.push_back(a[i]);
}
}
if(a[a.size() - 1] > a[a.size() - 2]){
ans.push_back(a[a.size() - 1]);
}
for(auto i : ans){
cout << i << " ";
}
}