結果

問題 No.1882 Areas of Triangle
ユーザー tentententen
提出日時 2022-04-02 16:33:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 268 ms / 2,000 ms
コード長 1,330 bytes
コンパイル時間 2,730 ms
コンパイル使用メモリ 78,416 KB
実行使用メモリ 58,348 KB
最終ジャッジ日時 2024-05-01 12:50:16
合計ジャッジ時間 6,081 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
50,440 KB
testcase_01 AC 51 ms
50,476 KB
testcase_02 AC 53 ms
50,280 KB
testcase_03 AC 53 ms
50,432 KB
testcase_04 AC 235 ms
58,348 KB
testcase_05 AC 268 ms
58,044 KB
testcase_06 AC 228 ms
57,708 KB
testcase_07 AC 53 ms
50,268 KB
testcase_08 AC 53 ms
50,388 KB
testcase_09 AC 53 ms
50,332 KB
testcase_10 AC 54 ms
50,576 KB
testcase_11 AC 53 ms
50,448 KB
testcase_12 AC 53 ms
50,212 KB
testcase_13 AC 53 ms
50,308 KB
testcase_14 AC 53 ms
50,208 KB
testcase_15 AC 53 ms
50,456 KB
testcase_16 AC 55 ms
50,452 KB
testcase_17 AC 59 ms
50,524 KB
testcase_18 AC 88 ms
51,492 KB
testcase_19 AC 117 ms
52,404 KB
testcase_20 AC 116 ms
52,468 KB
testcase_21 AC 116 ms
52,396 KB
testcase_22 AC 131 ms
52,688 KB
testcase_23 AC 181 ms
54,912 KB
testcase_24 AC 184 ms
54,824 KB
testcase_25 AC 53 ms
50,244 KB
testcase_26 AC 53 ms
50,652 KB
testcase_27 AC 54 ms
50,484 KB
testcase_28 AC 53 ms
50,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        long k = sc.nextLong() * 2;
        long[] values = new long[n];
        for (int i = 0; i < n; i++) {
            values[i] = sc.nextInt();
        }
        Arrays.sort(values);
        int left = 0;
        long ans = 0;
        for (int i = n - 1; i >= 0; i--) {
            while (left < n && values[left] * values[i] < k) {
                left++;
            }
            ans += n - left;
        }
        System.out.println(ans);
    }
}


class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0