如果发现广告等破坏行为,请尽量将条目恢复到较早的版本而不是把相应内容直接删除,谢谢合作。
URAL/1026
来自"NOCOW"
< URAL
//C++ Accepted //0.046 504 KB //桶排优化 #include<stdio.h> int main() { int n,k,tmp,type=0; int f[50001]={0}; int v[50001]={0}; scanf("%d",&n); for(k=n;k>0;k--) { scanf("%d",&tmp); f[tmp]+=1; } for(k=1;k<=50000;k++) if(f[k]) { type+=1; v[type]=k; } char s[3]; scanf("%s",&s) ; scanf("%d",&k); int ans=0; for(;k>0;k--) { scanf("%d",&tmp); while(tmp>0) { ans+=1; tmp-=f[v[ans]]; } printf("%d\n",v[ans]); ans=0; } return 0; }
VAR a:array [1..100000] of longint; i,j,n:longint; s:string; Procedure Qsort(low,high:longint); VAR i,j,t,mid:longint; BEGIN i:=low; j:=high; mid:=a[(low+high) div 2]; repeat while a[i]<mid do inc(i); while a[j]>mid do dec(j); if i<=j then BEGIN t:=a[i]; a[i]:=a[j]; a[j]:=t; inc(i); dec(j); END; until i>j; if low<j then Qsort(low,j); if i<high then Qsort(i,high); END; BEGIN readln(n); for i:=1 to n do readln(a[i]); Qsort(1,n); readln(s); readln(n); for i:=1 to n do BEGIN readln(j); writeln(a[j]); END; END.