https://vjudge.net/contest/379146#rank
package 第四次;
import java.util.*;
public class B {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int x=sc.nextInt();
int y=sc.nextInt();
int a[]=new int[n];
int num=0;
for(int i=0;i<n;i++){
a[i]=sc.nextInt();
if(x>=a[i]){
num++;
}
}
if(x>y){
System.out.println(n);
}else{
if(num%2==0)
{
System.out.println(num/2);
}
else
{
System.out.println(num/2+1);
}
}
}
}
package 第四次;
import java.util.*;
public class E {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int i=0;
for (i=0; n < m; i++){
if (m % 2 == 0)
m = m / 2;
else
m++;
}
System.out.println(i+n-m);
}
}
package SA;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int k=sc.nextInt();
int count=1;
int m=1;
int arr[]=new int[n];
int x[]=new int[5001];
int y[]=new int[n];
int EW[][] =new int[k+1][5001];
for(int i=0;i<n;i++)
{
arr[i]=sc.nextInt();
x[arr[i]]++;
if(x[arr[i]]>k)
count=0;
}
if(count==0||k>n)
System.out.println("NO");
else
{
for(int i=0;i<n;i++)
{
if(m<=k)
{
y[i]=m;
EW[m][arr[i]]=1;
m++;
}
else
{
for(int j=1;j<=k;j++)
{
if(EW[j][arr[i]]==0)
{
y[i]=j;
EW[j][arr[i]]=1;
break;
}
}
}
}
System.out.println("YES");
for(int i=0;i<n;i++)
System.out.print(y[i]+" ");
}
}
}