結果

問題 No.77 レンガのピラミッド
ユーザー yukirinyukirin
提出日時 2016-03-03 19:48:06
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 727 bytes
コンパイル時間 11,562 ms
コンパイル使用メモリ 226,164 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 06:48:56
合計ジャッジ時間 12,308 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 WA -
testcase_05 AC 1 ms
6,940 KB
testcase_06 RE -
testcase_07 AC 2 ms
6,940 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
testcase_15 WA -
testcase_16 RE -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 RE -
testcase_22 RE -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

var sc = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	ns, sum := make([]int, n), 0
	for i := range ns {
		c := nextInt()
		sum += c
		ns[i] = c
	}

	h := 0
	for i := 1; ; i++ {
		if i*i > sum {
			h = i - 1
			if h*2-1 > len(ns) {
				h = n/2 + 1
			}
			break
		}
	}

	count := h - ns[h-1]
	for i := 0; i < h-1; i++ {
		count += ns[i] - (i + 1)
		count += ns[i+h] - (h - 1 - i)
	}

	for _, v := range ns[h*2-1:] {
		count += v
	}
	fmt.Println(count)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextLine())
	return i
}
0