|
|
вернуться в форумWA 2, pls help me, what's wrong? #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? Please explain your solution |
|
|