結果

問題 No.1564 Sum of Products of Pairs
ユーザー scrappyscrappy
提出日時 2022-10-11 13:58:56
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 494 bytes
コンパイル時間 15,220 ms
コンパイル使用メモリ 211,780 KB
実行使用メモリ 5,516 KB
最終ジャッジ日時 2023-09-07 15:26:12
合計ジャッジ時間 14,538 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 21 ms
5,516 KB
testcase_04 AC 3 ms
4,384 KB
testcase_05 WA -
testcase_06 AC 20 ms
5,508 KB
testcase_07 AC 13 ms
5,492 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 13 ms
5,500 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 21 ms
5,516 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,384 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,388 KB
testcase_30 AC 1 ms
4,384 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0, 100000*7+2), 100000*7+2)

	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	ss := strings.Fields(sc.Text())
	A := make([]int, 2*N)
	for i, s := range ss {
		A[i], _ = strconv.Atoi(s)
	}

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

	sum := 0
	for i := 0; i < 2*N; i += 2 {
		sum += A[i] * A[i+1]
	}

	fmt.Println(sum)
}
0