Submission

Status:
P--PP---P-

Score: 40

User: MiyaZaki1072

Problemset: Maximum Adjacent

Language: cpp

Time: 0.002 second

Submitted On: 2025-03-16 13:46:31

#include <bits/stdc++.h>
using namespace std;
vector<double>vec;
double calc(string x){
    double ret = 0;
    int cnt=0,dec=0;
    bool neg=false;
    for(auto &r:x){
        if(r=='-')neg=true;
        if(r=='.')dec=cnt-1;
        else {
            ret*=10;
            ret+=(r-'0');
        }
        cnt++;
    }
    if(neg)return -ret/(pow(10,dec));
    else return ret/(pow(10,dec));
}
int main(){
    cin.tie(0)->sync_with_stdio(0);
    while(1){
        string x;cin>>x;
        if(x.size() == 1 && isalpha(x[0]))break;
        vec.push_back(calc(x));
    }
    vector<double>ans;
    for(int i=0;i<vec.size();i++){
        bool ch=true;
        if(i>0 && vec[i-1] > vec[i])ch=false;
        if(i<vec.size()-1 && vec[i+1] > vec[i])ch=false;
        if(ch)ans.push_back(vec[i]);
    }
    for(auto &x:ans)cout<<fixed<<setprecision(0)<<x<<" ";
}