#include <bits/stdc++.h>
using namespace std;
int a[2000005];
int main()
{
long long n, sum = 0;
cin >> n;
vector <int> v;
for (int i = 0; i < n; ++i) {
cin >> a[i];
if (i < n / 3)
v.push_back (a[i]);
}
sort (v.begin (), v.end ());
for (int i = 0; i < v.size (); ++i)
cout << v[i] << " ";
for (int i = n / 3; i < n; ++i)
cout << a[i] << " ";
cout << "\n";
for(int i = n - n / 3; i < n; ++i) {
if (a[i] > 0 && a[i] % 2 == 0)
sum += a[i];
cout << sum;
return 0;
Объяснение:
Вот код
#include <bits/stdc++.h>
using namespace std;
int a[2000005];
int main()
{
long long n, sum = 0;
cin >> n;
vector <int> v;
for (int i = 0; i < n; ++i) {
cin >> a[i];
if (i < n / 3)
v.push_back (a[i]);
}
sort (v.begin (), v.end ());
for (int i = 0; i < v.size (); ++i)
cout << v[i] << " ";
for (int i = n / 3; i < n; ++i)
cout << a[i] << " ";
cout << "\n";
for(int i = n - n / 3; i < n; ++i) {
if (a[i] > 0 && a[i] % 2 == 0)
sum += a[i];
}
cout << sum;
return 0;
}
Объяснение:
Вот код