Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include "bits/stdc++.h"
- //#include "geometry.h"
- //#include "data_structure.h"
- using namespace std;
- using namespace chrono;
- #define all(a) a.begin(), a.end()
- #define allr(a) a.rbegin(), a.rend()
- mt19937 rnd(std::chrono::high_resolution_clock::now().time_since_epoch().count());
- typedef long long ll;
- typedef double ld;
- signed main() {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- srand(time(NULL));
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- ll n = 1e5;
- ll k = 1e4;
- vector<ll> a(n);
- for (ll i = 0; i < n; i++) {
- cin >> a[i];
- }
- sort(all(a));
- struct My{
- ll cnt = 0;
- ll start = 0;
- ll ind = 0;
- };
- a.resize(unique(all(a)) - a.begin());
- unordered_map<ll, My> used;
- bool fl = true;
- ll d = 0;
- ll g = 0;
- for (ll i = 0; i < n; i++) {
- for (ll j = i + 1; j < n; j++) {
- if (!used[a[j] - a[i]].start) {
- used[a[j] - a[i]].start = a[i];
- used[a[j] - a[i]].ind = i;
- }
- if (k - used[a[j] - a[i]].cnt > n - j) {
- used.erase(a[j] - a[i]);
- }
- used[a[j] - a[i]].cnt++;
- if (used[a[j] - a[i]].cnt == k-1) {
- d = a[j] - a[i];
- ll cnt = 0;
- cout << used[a[j] - a[i]].start << '\n';
- ll last = used[a[j] - a[i]].ind;
- for (ll f = used[a[j] - a[i]].ind+1; f < n&& cnt != k - 1; f++) {
- if (a[f] - a[last] == d) {
- cout <<a[f]<<'\n';
- last = f;
- cnt++;
- }
- }
- return 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement