結果

問題 No.216 FAC
ユーザー tyochiaityochiai
提出日時 2015-09-12 22:51:56
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 608 bytes
コンパイル時間 10,710 ms
コンパイル使用メモリ 226,668 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 03:20:55
合計ジャッジ時間 11,611 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

import (
	"fmt"
)

var (
	N int
	a []int
	b []int
)

func resolve() bool {
	score := 0
	others := make(map[int]int)
	for i := 0; i < N; i++ {
		if b[i] == 0 {
			score += a[i]
			continue
		}
		others[b[i]] += a[i]
	}
	for _, v := range others {
		if score < v {
			return false
		}
	}
	return true
}

func main() {
	fmt.Scanf("%d\n", &N)
	a = make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &a[i])
	}
	fmt.Scanf("\n")
	b = make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &b[i])
	}
	fmt.Scanf("\n")

	if resolve() {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
0