本帖最後由 駱顗安 於 2022-4-18 19:10 編輯
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Comparator;
- import java.util.TreeSet;
- public class P1 {
- BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- int t,n,c,s,l,k[];
- String raw[];
- boolean b;
- ArrayList<Integer> al=new ArrayList<Integer>();
- P1() throws Exception{
- raw=br.readLine().split(" ");
- n=raw.length;
- k=new int[n];
- for(int i=0;i<n;i++) k[i]=ip(i);
- t=Integer.parseInt(br.readLine());
- int index=Arrays.binarySearch(k, t);
- if(index<0) index=-index-1;
- else {
- while(index>0&&k[index-1]==t) index--;
- }
- System.out.println(index);
- }
- int ip(int y) {
- return Integer.parseInt(raw[y]);
- }
- public static void main(String[] args) throws Exception {
- new P1();
- }
- }
複製代碼 |