結果

問題 No.216 FAC
ユーザー tyochiaityochiai
提出日時 2015-07-19 00:44:25
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 559 bytes
コンパイル時間 10,732 ms
コンパイル使用メモリ 220,336 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 02:39:43
合計ジャッジ時間 11,558 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 1 ms
5,376 KB
testcase_04 AC 1 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 2 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() string {
	score := 0
	others := 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 "NO"
		}
	}
	return "YES"
}

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")
	fmt.Println(resolve())
}
0