結果

問題 No.1882 Areas of Triangle
ユーザー scrappyscrappy
提出日時 2022-10-20 13:19:42
言語 Go
(1.22.1)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 794 bytes
コンパイル時間 13,663 ms
コンパイル使用メモリ 212,940 KB
実行使用メモリ 7,792 KB
最終ジャッジ日時 2023-09-12 18:38:20
合計ジャッジ時間 16,318 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,356 KB
testcase_01 AC 1 ms
4,356 KB
testcase_02 AC 2 ms
4,356 KB
testcase_03 AC 1 ms
4,356 KB
testcase_04 AC 29 ms
7,792 KB
testcase_05 AC 32 ms
7,768 KB
testcase_06 AC 17 ms
7,656 KB
testcase_07 AC 1 ms
4,356 KB
testcase_08 AC 2 ms
4,356 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 2 ms
4,356 KB
testcase_11 AC 1 ms
4,356 KB
testcase_12 AC 1 ms
4,356 KB
testcase_13 AC 1 ms
4,356 KB
testcase_14 AC 1 ms
4,356 KB
testcase_15 AC 1 ms
4,360 KB
testcase_16 AC 2 ms
4,360 KB
testcase_17 AC 2 ms
4,356 KB
testcase_18 AC 2 ms
4,352 KB
testcase_19 AC 4 ms
4,352 KB
testcase_20 AC 3 ms
4,352 KB
testcase_21 AC 4 ms
4,356 KB
testcase_22 AC 4 ms
4,356 KB
testcase_23 AC 10 ms
5,500 KB
testcase_24 AC 9 ms
5,500 KB
testcase_25 AC 1 ms
4,356 KB
testcase_26 AC 1 ms
4,384 KB
testcase_27 AC 1 ms
4,356 KB
testcase_28 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 100000*11+2), 100000*11+2)
	sc.Scan()
	ss := strings.Fields(sc.Text())
	N, _ := strconv.Atoi(ss[0])
	K, _ := strconv.Atoi(ss[1])

	sc.Scan()
	tt := strings.Fields(sc.Text())
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i], _ = strconv.Atoi(tt[i])
	}

	sort.Slice(A, func(i, j int) bool { return A[i] < A[j] })

	k1 := sort.Search(N, func(i int) bool { return A[i]*A[N-1] >= 2*K })
	// k2 := sort.Search(N, func(i int) bool { return A[i]*A[0] >= 2*K })
	// fmt.Fprintln(os.Stderr, k1, k2)

	count := 0
	for i := k1; i < N; i++ {
		k := sort.Search(N, func(j int) bool { return A[i]*A[j] >= 2*K })
		count += N - k
	}
	fmt.Println(count)
}
0