Code:
#include "kth.h" #include<iostream> int minn(int x,int y){return x<y?x:y;}; int query_kth(int n_a, int n_b, int n_c, int k) { int pa=0,pb=0,pc=0,tmin; while(k) { int l=(k-2)/3; int t1=get_a(pa+l); int t2=get_b(pb+l); int t3=get_c(pc+l); tmin=minn(minn(t1,t2),t3); l++; if(tmin==t1) pa+=l; else if(tmin==t2) pb+=l; else if(tmin==t3) pc+=l; k-=l; } return tmin; }
原文:https://www.cnblogs.com/guangheli/p/11025008.html