結果

問題 No.1594 Three Classes
ユーザー ixrsixrs
提出日時 2021-07-09 21:57:19
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,319 ms / 2,000 ms
コード長 265 bytes
コンパイル時間 40 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,928 KB
最終ジャッジ日時 2024-04-28 00:09:14
合計ジャッジ時間 14,019 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,287 ms
12,928 KB
testcase_01 AC 73 ms
12,416 KB
testcase_02 AC 73 ms
12,288 KB
testcase_03 AC 106 ms
12,800 KB
testcase_04 AC 1,300 ms
12,800 KB
testcase_05 AC 1,319 ms
12,672 KB
testcase_06 AC 101 ms
12,800 KB
testcase_07 AC 130 ms
12,800 KB
testcase_08 AC 1,305 ms
12,672 KB
testcase_09 AC 1,282 ms
12,800 KB
testcase_10 AC 1,313 ms
12,800 KB
testcase_11 AC 1,308 ms
12,928 KB
testcase_12 AC 1,299 ms
12,928 KB
testcase_13 AC 76 ms
12,288 KB
testcase_14 AC 328 ms
12,928 KB
testcase_15 AC 225 ms
12,928 KB
testcase_16 AC 154 ms
12,544 KB
testcase_17 AC 138 ms
12,800 KB
testcase_18 AC 79 ms
12,160 KB
testcase_19 AC 82 ms
12,160 KB
testcase_20 AC 85 ms
12,416 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
es = gets.split.map(&:to_i)

ps = [0, 0, 0]
(0...(3 ** n)).each do |s|
  ps[0] = 0
  ps[1] = 0
  ps[2] = 0
  n.times.each do |i|
    ps[s % 3] += es[i]
    s /= 3
  end
  if ps[0] == ps[1] && ps[1] == ps[2]
    puts 'Yes'
    exit
  end
end
puts 'No'
0