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 <iostream>
#include <cmath>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#define M 1000000007
#define pii pair<int, int>
typedef long long ll;
using namespace std;
int main() {
int n, k;
cin >> n >> k;
multiset<int>set1;
vector<int>vec(n+k);
ll sum = 0;
for (int i = 0; i < n + k; i++) {
cin >> vec[i];
set1.insert(vec[i]);
sum += vec[i];
}
for (int i = 0; i < n + k; i++) {
ll sum1 = sum - vec[i];
set1.erase(set1.find(vec[i]));
auto it = set1.begin();
int a1 = *it;
++it;
int a2 = *it;
int d = a2 - a1;
ll sum2 = (2 * a1 + (n - 1) * d) * n / 2;
if (sum2 == sum1) {
int cnt = 0;
for (int j = 0; j < n + k; j++) {
if (j != i) {
cnt++;
cout << vec[j];
if (cnt != n)
cout << " ";
}
}
break;
}
set1.insert(vec[i]);
}
}
# | 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... |
# | 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... |