結果

問題 No.1505 Zero-Product Ranges
ユーザー simansiman
提出日時 2021-05-15 16:58:14
言語 Ruby
(3.3.0)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 222 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 25,856 KB
最終ジャッジ日時 2024-04-14 07:26:45
合計ジャッジ時間 9,442 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
12,288 KB
testcase_01 AC 87 ms
12,160 KB
testcase_02 AC 87 ms
12,288 KB
testcase_03 AC 175 ms
25,600 KB
testcase_04 AC 178 ms
25,728 KB
testcase_05 AC 124 ms
17,664 KB
testcase_06 AC 125 ms
17,280 KB
testcase_07 AC 118 ms
15,488 KB
testcase_08 AC 121 ms
16,768 KB
testcase_09 AC 119 ms
16,128 KB
testcase_10 AC 124 ms
16,000 KB
testcase_11 AC 127 ms
17,408 KB
testcase_12 AC 111 ms
15,488 KB
testcase_13 AC 144 ms
19,456 KB
testcase_14 AC 140 ms
18,944 KB
testcase_15 AC 175 ms
23,552 KB
testcase_16 AC 179 ms
25,600 KB
testcase_17 AC 179 ms
25,856 KB
testcase_18 AC 179 ms
25,600 KB
testcase_19 AC 88 ms
12,288 KB
testcase_20 AC 88 ms
12,288 KB
testcase_21 AC 89 ms
12,160 KB
testcase_22 AC 177 ms
25,600 KB
testcase_23 AC 176 ms
25,600 KB
testcase_24 AC 173 ms
23,424 KB
testcase_25 AC 170 ms
23,296 KB
testcase_26 AC 173 ms
23,552 KB
testcase_27 AC 170 ms
23,424 KB
testcase_28 AC 170 ms
23,552 KB
testcase_29 AC 174 ms
25,344 KB
testcase_30 AC 175 ms
25,600 KB
testcase_31 AC 173 ms
23,552 KB
testcase_32 AC 139 ms
18,688 KB
testcase_33 AC 130 ms
18,176 KB
testcase_34 AC 137 ms
19,072 KB
testcase_35 AC 125 ms
17,408 KB
testcase_36 AC 128 ms
17,664 KB
testcase_37 AC 134 ms
18,432 KB
testcase_38 AC 133 ms
18,176 KB
testcase_39 AC 134 ms
18,304 KB
testcase_40 AC 133 ms
18,560 KB
testcase_41 AC 140 ms
19,328 KB
testcase_42 AC 91 ms
12,544 KB
testcase_43 AC 94 ms
13,184 KB
testcase_44 AC 94 ms
12,672 KB
testcase_45 AC 97 ms
13,056 KB
testcase_46 AC 90 ms
12,544 KB
testcase_47 AC 95 ms
13,312 KB
testcase_48 AC 91 ms
12,800 KB
testcase_49 AC 91 ms
12,288 KB
testcase_50 AC 95 ms
12,672 KB
testcase_51 AC 94 ms
12,928 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)
all = N * (N + 1) / 2
cnt = 0
cur = 0

A.each do |a|
  if a == 0
    cnt += cur * (cur + 1) / 2
    cur = 0
  else
    cur += 1
  end
end

cnt += cur * (cur + 1) / 2
puts all - cnt
0