hiho week 143 register

Ended

Participants:1650

Verdict:Accepted
Score:100 / 100
Submitted:2017-03-30 10:17:33

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<iostream>
#include<vector>
#include<iterator>
using namespace std;
int main()
{
    size_t alphnum;
    cin >> alphnum;
    vector<int> word;
    size_t i;
    while (cin >> i && word.size() <= alphnum)
        word.push_back(i);
    auto it = word.rbegin();
    int prev = *it++;
    while (it != word.crend() && *it < prev)
        prev = *it++;
    word.erase(it.base(), word.end());
    if (word.empty())
        cout << "1";
    for (auto a : word)
        cout << a << " ";
    cout << endl;
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX