제출 #1027434

#제출 시각아이디문제언어결과실행 시간메모리
1027434blacktulipTable Tennis (info1cup20_tabletennis)C++17
87 / 100
3093 ms7116 KiB
#include <bits/stdc++.h> using namespace std; typedef long long lo; #define fi first #define se second #define endl "\n" #define pb push_back #define int long long #define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define FOR for(int i=1;i<=n;i++) #define mid ((start+end)/2) #define ort ((bas+son)/2) #define _ << " " << const lo inf = 1000000000; const lo li = 500005; const lo mod = 1000000007; int n,m,a[li],k,flag,t; int cev; string s; vector<int> v; inline void yaz(int l,int r,int sum){ //~ cout<<l _ r _ sum<<endl; while(l<=r){ if(l==r)break; if(a[l]+a[r]==sum){v.pb(a[l]),v.pb(a[r]);l++;r--;continue;} if(a[l]+a[r]<sum)l++; else r--; } sort(v.begin(),v.end()); for(auto go:v)cout<<go<<" "; exit(0); } int32_t main(void){ fio(); cin>>n>>k; for(int i=1;i<=n+k;i++){ cin>>a[i]; } sort(a+1,a+n+k+1); for(int i=1;i<=k+1;i++){ for(int j=n-1+i;j<=n+k;j++){ int sum=a[i]+a[j]; int hak=k-(i-1+n+k-j); int bas=i; int son=j; while(bas<=son){ if(bas==son){hak--;break;} if(a[bas]+a[son]==sum){bas++;son--;continue;} hak--; if(a[bas]+a[son]<sum)bas++; else son--; } if(hak<0)continue; //~ cout<<i _ j _ sum _ a[i] _ a[j]<<endl; yaz(i,j,sum); } } return 0; }
#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...