Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Kx
Problemset: Maximum Adjacent
Language: cpp
Time: 0.002 second
Submitted On: 2026-03-18 16:21:24
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> num;
bool stop = false;
while(!stop) {
string s; cin >> s;
if(s.length() == 1) {
int n = (int)s[0];
if(n >= 'a' && n <= 'z' || n >= 'A' && n <= 'Z') {
stop = true;
} else {
num.push_back(stoi(s));
}
} else {
num.push_back(stoi(s));
}
}
vector<int> res;
int sz = (int)num.size();
for(int i = 0; i < sz; ++i) {
if(i > 0 && i < sz - 1) {
int a = num[i - 1], b = num[i], c = num[i + 1];
if(b > a && b > c) {
res.push_back(b);
}
} else if(i == 0) {
if(num[i] > num[i + 1]) res.push_back(num[i]);
} else if(i == sz - 1) {
if(num[i] > num[i - 1]) res.push_back(num[i]);
}
}
for(auto x : res) {
cout << x << ' ';
}
return 0;
}