//190ms 1704kb
#include <algorithm>
int query_kth(const int *A,int na,const int *B,int nb,const int *C,int n_c, int k)
{
const int myINF=0x7fffffff;
int nowa=-1,nowb=-1,nowc=-1,delta,a,b,c,mn;
while(k>2)
{
delta=k/3;
a=nowa+delta<=n_a?A[nowa+delta]:myINF,
b=nowb+delta<=n_b?B[nowb+delta]:myINF,
c=nowc+delta<=n_c?C[nowc+delta]:myINF;
mn=std::min(a,std::min(b,c));
if(mn==a) nowa+=delta;
else if(mn==b) nowb+=delta;
else if(mn==c) nowc+=delta;
k-=delta;
}
int AA[7];
AA[1]=A[nowa+1], AA[2]=A[nowa+2];
AA[3]=B[nowb+1], AA[4]=B[nowb+2];
AA[5]=C[nowc+1], AA[6]=C[nowc+2];
std::sort(AA+1,AA+7);
return AA[k];
}
| Compilation | N/A | N/A | Compile Error | Score: N/A | 显示更多 |