Created
September 20, 2017 02:07
-
-
Save AdrianoPereira/37f928972bc86eca01e6622c66d00367 to your computer and use it in GitHub Desktop.
Implementação em java do problema do URI 2663 - Fase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
public class Main { | |
public static void main (String[] args ) throws IOException{ | |
InputStreamReader isr = new InputStreamReader(System.in); | |
BufferedReader br = new BufferedReader(isr); | |
int competidores = Integer.parseInt(br.readLine()); | |
int vagas = Integer.parseInt(br.readLine()); | |
int pontos; | |
int atual; | |
int rank[] = new int[1001]; | |
int ans = 0; | |
for(int x=0; x<competidores; x++){ | |
atual = Integer.parseInt(br.readLine()); | |
rank[atual]++; | |
} | |
for(int x=1000; x>=0; x--){ | |
if(vagas>0){ | |
if(rank[x]!=0){ | |
vagas -=rank[x]; | |
ans+=rank[x]; | |
} | |
}else{ | |
break; | |
} | |
} | |
System.out.println(ans); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment