ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1663. The Hobbit or There and Back Again 2

WA 2, pls help me, what's wrong?
Posted by Bogdanov Klim 29 Jul 2017 20:13
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <cctype>
#include <algorithm>
#include <math.h>
#include <iostream>

using namespace std;

int main() {
int N, ch;
int h = 1;
int max = 0;
int second_max = 0;
cin >> N;
vector <int> m(N);
vector<int> v(N);
vector<int> k;
for (int i = 0; i < N; i++)
{
    cin >> ch;
    v[i] = ch;
}
for(int i = 1; i < N; i++)
{
    if(v[i] > max)
    {
        second_max = max;
        max = v[i];
    }
    else
    {
        if (v[i] > second_max)
        {
            second_max = v[i];
        }
    }
}
for (int i = 0; i < N; i++)
{
    if (v[i] != max && v[i] != second_max && v[i] != v[0])
    {
        k.push_back(v[i]);
    }
}
sort(begin(k), end(k));
m[0] = v[0];
m[1] = second_max;
m[N - 1] = max;
for (int i = 2; i < N-1; i++)
{
    m[i] = k[k.size() - h];
    h++;
}
for (auto j = 0; j < N; j++)
{
    for (auto i = 0; i < N; i++)
    {
        if(m[j] == v[i])
        {
            cout << i + 1 << " ";
            i = N;
        }
    }
}
    return 0;
}
Re: WA 2, pls help me, what's wrong?
Posted by Mahilewets 29 Jul 2017 23:10
Please explain your solution