#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
const int MXN = 100005;
int n, a[MXN];
vector<int> L, R;
bool check(int l) {
for (int i = l; i < n; i++) {
if (L[1] - L[0] == a[i] - L.back()) L.push_back(a[i]);
else if (R.size() < 2) R.push_back(a[i]);
else if (R[1] - R[0] == a[i] - R.back()) R.push_back(a[i]);
else return false;
}
if (R.empty()) {
R.push_back(L.back());
L.pop_back();
}
cout << L.size() << endl;
for (auto &i : L) cout << i << ' ';
cout << endl << R.size() << endl;
for (auto &i : R) cout << i << ' ';
cout << endl;
return true;
}
void solve() {
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
if (n == 2) {
cout << 1 << endl << a[0] << endl << 1 << endl << a[1] << endl;
return;
}
L = {a[0], a[1]};
R = {};
if (check(2)) return;
L = {a[0], a[2]};
R = {a[1]};
if (check(3)) return;
L = {a[1], a[2]};
R = {a[0]};
if (check(3)) return;
cout << -1 << endl;
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
328 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
328 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
3308 KB |
Output is correct |
2 |
Correct |
25 ms |
3280 KB |
Output is correct |
3 |
Correct |
21 ms |
3392 KB |
Output is correct |
4 |
Correct |
22 ms |
3280 KB |
Output is correct |
5 |
Correct |
22 ms |
3372 KB |
Output is correct |
6 |
Correct |
21 ms |
3168 KB |
Output is correct |
7 |
Correct |
24 ms |
3348 KB |
Output is correct |
8 |
Correct |
21 ms |
3280 KB |
Output is correct |
9 |
Incorrect |
14 ms |
2484 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
328 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |