# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1085562 | serifefedartar | Drvca (COCI19_drvca) | C++17 | 18 ms | 2660 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
#define f first
#define s second
#define LOGN 21
const ll MOD = 1e9 + 7;
const ll MAXN = 2e5 + 100;
vector<int> h;
int main() {
fast;
int N;
cin >> N;
h = vector<int>(N+1, 0);
for (int i = 1; i <= N; i++)
cin >> h[i];
sort(h.begin(), h.end());
for (int i = 1; i <= 2; i++) {
for (int j = i+1; j <= 3; j++) {
vector<int> sequence, other_sequence;
for (int k = 1; k <= 3; k++) {
if (i != k && j != k)
other_sequence.push_back(h[k]);
}
sequence.push_back(h[i]);
sequence.push_back(h[j]);
for (int i = 4; i <= N; i++) {
if (h[i] == sequence.back() * 2 - sequence.end()[-2])
sequence.push_back(h[i]);
else
other_sequence.push_back(h[i]);
}
set<int> diff;
for (int i = 1; i < other_sequence.size(); i++)
diff.insert(other_sequence[i] - other_sequence[i-1]);
if (diff.size() <= 1) {
if (other_sequence.size() == 0) {
other_sequence.push_back(sequence.back());
sequence.pop_back();
}
cout << sequence.size() << "\n";
for (auto u : sequence)
cout << u << " ";
cout << "\n";
cout << other_sequence.size() << "\n";
for (auto u : other_sequence)
cout << u << " ";
cout << "\n";
exit(0);
}
}
}
cout << "-1\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |