Submission

Status:
PPPPPPPPPP

Score: 100

User: osensunny

Problemset: Maximum Adjacent

Language: cpp

Time: 0.002 second

Submitted On: 2025-03-20 13:26:18

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

char c;
int num, p;
bool checkNegative;
vector<int> vect;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	num = 0;
	while(true){
		scanf("%c", &c);
		if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) break;
		else if(c == ' ' || c == '\n'){
			if(checkNegative) vect.push_back(-num);
			else vect.push_back(num);
			num = 0;
			checkNegative = false;
		}
		else if(c == '-'){
			checkNegative = true;
			continue;
		}
		else{
			num *= 10;
			num += c - '0';
		}
	}
	
	for(int i=0; i<vect.size(); i++){
		if(i == 0 && vect[i] > vect[i+1]) cout << vect[i] << ' ';
		else if(i == vect.size()-1 && vect[i] > vect[i-1]) cout << vect[i] << ' ';
		else if(vect[i] > vect[i-1] && vect[i] > vect[i+1]) cout << vect[i] << ' ';
	}
	
	return 0;
}