Submission #1140616

#TimeUsernameProblemLanguageResultExecution timeMemory
1140616Fikrat_AsadzadehTable Tennis (info1cup20_tabletennis)C++20
100 / 100
457 ms6300 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define FORI(i, n) for(ll i = 0; i < n; i++) #define FOR(i, n) for(ll i = 1; i <= n; i++) typedef vector < ll > vl; typedef set < ll > setl; #define ff first #define ss second #define all(v) v.begin(), v.end() #define pll pair<ll, ll> #define db double #define nll cout << "\n" #define nl "\n" #define sync ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); const ll mod = 1e9 + 7; const int MAX = 5e5 + 5; const int imax = 2147483647; ll n, m, k, q, l, r, x, y, nd; ll a[MAX], b[MAX], c[MAX]; // ll a, b, c; void solve(){ cin >> n >> k; FOR(i, n + k + 1)cin >> a[i]; for(ll i = n + k + 1; i >= 1; i--) { FOR(j, k + 1){ ll l = j, r = i, cn = 0; if(j >= i)break; vl res; ll gl = a[l] + a[r]; while(l < r && cn <= k){ if(a[l] + a[r] == gl){ res.push_back(a[l]); res.push_back(a[r]); l++; r--; } else if(a[l] + a[r] > gl){ r--; cn++; } else l++, cn++; } if(res.size() == n){ sort(all(res)); for(auto i : res)cout << i << " "; return; } } } } signed main(){ // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); sync; ll t = 1; // cin >> t; FOR(i, t){ // cout << "Case #" << i << ": "; solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...