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>
#pragma warning(disable : 4996)
#pragma warning(disable : 6031)
#define USACO freopen("moocast.in", "r", stdin); freopen("moocast.out", "w+", stdout)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
using namespace std;
ll binpow(ll a, ll x, ll m) {
ll ans = 1, md = a % m;
for (int i = 0; i < 63; i++) {
if (x & ((ll)1 << i)) ans = (ans * md) % m;
md = (md * md) % m;
}
return ans;
}
vector<ll> gcd(ll a, ll b) {
if (b == 0) {
return { a, 1, 0 };
}
vector<ll> d = gcd(b, a % b);
return { d[0], d[2], d[1] - d[2] * (a / b) };
}
ll lcm(ll a, ll b) {
return a * b / gcd(a, b)[0];
}
int a[200000], ans[150000];
void solve() {
int n, k;
cin >> k >> n;
n += k;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++) {
for (int j = i + k - 1; j < n; j++) {
int cnt = 0;
for (int l = i, r = j; 2 * cnt < k; l++) {
while (r > l && a[j] - a[r] < a[l] - a[i]) r--;
if (r <= l) break;
if (r - l + 1 < k - 2 * cnt) break;
if (a[j] - a[r] == a[l] - a[i]) {
ans[cnt] = a[l];
ans[k - 1 - cnt] = a[r];
cnt++;
r--;
}
}
if (2 * cnt == k) {
for (int c = 0; c < k; c++) cout << ans[c] << " ";
return;
}
}
}
}
int main() {
//USACO;
fastIO;
solve();
}
Compilation message (stderr)
tabletennis.cpp:2: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
2 | #pragma warning(disable : 4996)
|
tabletennis.cpp:3: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
3 | #pragma warning(disable : 6031)
|
# | 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... |