#include "bits/stdc++.h"
#define pb(x) push_back(x)
#define fil(x, y) memset(x, y, sizeof(x))
#define ll long long
#define ff first
#define ss second
#define printp(x) x.ff << " " << x.ss
#define pii pair<int,int>
#define pll pair<long long,long long>
#define mp(x, y) make_pair(x,y)
#define inf 1073741823
#define infll 4611686018427387903
#define M 1000000007
#define db(x) cout << x << " ";
#define N 200007
#define sz size
#define sm 0.0000007
#define ins insert
#define ers erase
#define all(k) k.begin(), k.end()
#define cnt count
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
int main()
{
fastio;
int n;
cin >> n;
int ara[n];
for(int i = 0;i < n;i++)
{
cin >> ara[i];
}
sort(ara, ara + n);
bool g = 0;
for(int i = 2;i < n;i++)
{
if(ara[i] - ara[i - 1] != (ara[2] - ara[1]))
{
g = 1;
break;
}
}
if(g == 0)
{
cout << 1 << endl << ara[0] << endl;
cout << n - 1 << endl;
for(int i = 1;i < n;i++)
cout << ara[i] << " ";
cout << endl;
}
else
{
map <int, int> amio;
bool tmio[n];
int z;
bool k = 0;
for(int i = 1;i < n;i++)
{
int x = ara[i] - ara[0];
if(amio[x] == 0)
{
fil(tmio, 0);
tmio[0] = tmio[i] = 1;
z = 2;
int y = i;
for(int j = i + 1;j < n;j++)
{
if(ara[j] - ara[y] > x)
break;
else if(ara[j] - ara[y] == x)
{
y = j;
tmio[j] = 1;
z++;
}
}
bool g = 0;
int f = -1;
k = 0;
for(int j = 0;j < n;j++)
{
if(g == 0 && tmio[j] == 0)
{
y = j;
g = 1;
}
else if(g == 1 && tmio[j] == 0)
{
if(f == -1)
{
f = ara[j] - ara[y];
y = j;
}
else if(f != -1 && ara[j] - ara[y] != f)
{
k = 1;
break;
}
}
}
if(k == 0)
break;
}
}
if(k == 1)
{
cout << z << endl;
for(int i = 0;i < n;i++)
{
if(tmio[i] == 1)
{
cout << ara[i] << " ";
}
}
cout << endl << n - z << endl;
for(int i = 0;i < n;i++)
{
if(tmio[i] == 0)
{
cout << ara[i] << " ";
}
}
cout << endl;
}
else
cout << -1 << endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1076 ms |
1408 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |