Submission

Status:
PPPPPPPPPP

Score: 100

User: Ecir

Problemset: Maximum Adjacent

Language: cpp

Time: 0.003 second

Submitted On: 2025-03-13 22:05:08

#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
#define twod array<ll,2>
vector<int> ans;
vector<int> vct;
int mX=0;
unordered_map<int,bool> mp;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	bool b=0;
	string c;
	while(cin >> c){
		int z=0;
		if(!(c[0]=='-' || (c[0]>='0' && c[0]<='9'))){
			break;
		}
		if(c[0]=='-'){
			for(int i=1;i<c.size();i++){
				z*=10;
				z+=int(c[i]-'0');
			}
			z*=(-1);
		}
		else{
			for(int i=0;i<c.size();i++){
				z*=10;
				z+=int(c[i]-'0');
			}
		}
		vct.push_back(z);
	}
	if(vct[0]>vct[1])ans.push_back(vct[0]);
	for(int i=1;i<=vct.size()-2;i++) if(vct[i]>vct[i-1] && vct[i]>vct[i+1]) ans.push_back(vct[i]);
	if(vct[vct.size()-1]>vct[vct.size()-2]) ans.push_back(vct[vct.size()-1]);
	for(auto e:ans) cout << e << " ";
	return 0;
}