#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define int long long
const int sz = 4e5 + 5;
const int mod = 1e9 + 7;
signed main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, m;
cin >> n >> m;
vector<int>v(n + m);
map<int, int>mp;
for (int i = 0; i < n + m; i++) {
cin >> v[i];
mp[v[i]] = i + 1;
}
sort(all(v));
vector<int>ans;
vector<int>a, b;
for (int i = 0; i < n / 2; i++) {
if (i % 2 == 0)a.push_back(v[i]);
else b.push_back(v[i]);
}
for (int i = n / 2; i < n; i++) {
if (i % 2 == 1)a.push_back(v[i]);
else b.push_back(v[i]);
}
int sum1 = 0, sum2 = 0;
for (auto i : a) {
sum1 += i;
}
for (auto i : b) {
sum2 += i;
}
if (sum1 == sum2) {
for (int i = 0; i < n; i++)cout << mp[v[i]] << ' ';
}
else {
int x = sum1 - sum2;
for (int i = 0; i < n / 2;i++) {
if (v[n] - a[i] == -x) {
a[i] = v[n];
x = 0;
break;
}
}
for (int i = 0; i < n / 2; i++) {
if (v[n] - b[i] == -x) {
b[i] = v[n];
x = 0;
break;
}
}
for (auto i : a)cout << mp[i] << ' ';
for (auto i : b)cout << mp[i] << ' ';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
2132 KB |
Output not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
77 ms |
13168 KB |
Output not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output not subsequence of input |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output not sorted |
2 |
Halted |
0 ms |
0 KB |
- |