結果

問題 No.1882 Areas of Triangle
ユーザー ripityripity
提出日時 2022-03-20 11:27:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 722 ms / 2,000 ms
コード長 1,223 bytes
コンパイル時間 3,631 ms
コンパイル使用メモリ 77,420 KB
実行使用メモリ 52,296 KB
最終ジャッジ日時 2024-04-18 18:44:19
合計ジャッジ時間 11,480 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
41,516 KB
testcase_01 AC 126 ms
41,568 KB
testcase_02 AC 127 ms
41,748 KB
testcase_03 AC 121 ms
41,820 KB
testcase_04 AC 722 ms
51,152 KB
testcase_05 AC 707 ms
49,100 KB
testcase_06 AC 700 ms
52,296 KB
testcase_07 AC 135 ms
41,872 KB
testcase_08 AC 127 ms
41,560 KB
testcase_09 AC 129 ms
41,752 KB
testcase_10 AC 127 ms
41,652 KB
testcase_11 AC 129 ms
41,524 KB
testcase_12 AC 132 ms
41,736 KB
testcase_13 AC 113 ms
41,764 KB
testcase_14 AC 126 ms
41,700 KB
testcase_15 AC 146 ms
41,832 KB
testcase_16 AC 169 ms
42,396 KB
testcase_17 AC 183 ms
42,852 KB
testcase_18 AC 205 ms
44,668 KB
testcase_19 AC 289 ms
48,004 KB
testcase_20 AC 283 ms
48,064 KB
testcase_21 AC 299 ms
48,228 KB
testcase_22 AC 292 ms
48,156 KB
testcase_23 AC 439 ms
48,752 KB
testcase_24 AC 458 ms
48,432 KB
testcase_25 AC 114 ms
41,992 KB
testcase_26 AC 114 ms
41,576 KB
testcase_27 AC 129 ms
41,956 KB
testcase_28 AC 130 ms
41,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    
    public static PrintWriter pw = new PrintWriter(System.out);
    public static Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) {
        
        int t = 1;
        while( t > 0 ) {
            solve();
            t--;
        }
        
        pw.flush();
        
    }
    
    static void solve() {
        
        int N = sc.nextInt();
        long K = sc.nextLong();
        long[] a = new long[N+1];
        long ans = 0;
        
        a[N] = (long)1<<60;
        for( int i = 0; i < N; i++ ) {
            a[i] = sc.nextInt();
        }
        
        Arrays.sort(a);
        
        for( int i = 0; i < N; i++ ) {
            int res = lowerBound(a,(2*K+a[i]-1)/a[i]);
            if( res != -1 ) ans += N-res;
        }
        
        pw.println(ans);
        
    }
    
    static int lowerBound(long[] a, long val) {
        
        int low = 0;
        int high = a.length-1;
        int mid = 0;
        while( low < high ) {
            mid = (low+high)/2;
            if( a[mid] < val ) low = mid+1;
            else high = mid;
        }
        
        return high;
        
    }
    
}
0