제출 #435479

#제출 시각아이디문제언어결과실행 시간메모리
435479zaneyuTable Tennis (info1cup20_tabletennis)C++14
100 / 100
389 ms33984 KiB
/*input 4 3 1 2 3 4 8 10 20 */ #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_sett; //order_of_key #of elements less than x // find_by_order kth element typedef long long int ll; #define ld double #define pii pair<ll,ll> #define f first #define s second #define pb push_back #define REP(i,n) for(int i=0;i<n;i++) #define REP1(i,n) for(int i=1;i<=n;i++) #define FILL(n,x) memsett(n,x,sizeof(n)) #define ALL(_a) _a.begin(),_a.end() #define sz(x) (int)x.size() const ll maxn=2e5+5; int arr[maxn]; int ar[maxn],l[maxn],r[maxn]; int32_t main(){ ios::sync_with_stdio(false),cin.tie(0); int n,k; cin>>n>>k; REP(i,n+k) cin>>arr[i]; map<int,int> mp; if(n>=3*k){ REP(i,2*k){ for(int j=n+k-1;j>=n-k;j--){ mp[arr[i]+arr[j]]++; } } } else{ REP(i,n+k){ REP(j,i) mp[arr[i]+arr[j]]=k; } } for(auto x:mp){ if(x.s>=k){ int pp=0,lp=0,rp=0; int s=x.f,ans=0; REP(a,n+k){ while(pp>0 and ar[pp]+arr[a]>s) --pp; if(pp>0 and ar[pp]+arr[a]==s){ ++ans,l[lp++]=ar[pp],r[rp++]=arr[a]; } else ar[++pp]=arr[a]; if(ans==(n/2)) break; } if(ans==(n/2)){ REP(i,n/2) cout<<l[n/2-i-1]<<' '; REP(i,n/2) cout<<r[i]<<' '; 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...