結果

問題 No.2053 12345...
ユーザー tomeruntomerun
提出日時 2022-08-21 12:55:52
言語 Crystal
(1.11.2)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 235 bytes
コンパイル時間 13,275 ms
コンパイル使用メモリ 294,656 KB
実行使用メモリ 16,128 KB
最終ジャッジ日時 2024-04-18 12:43:39
合計ジャッジ時間 14,196 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 8 ms
5,504 KB
testcase_04 AC 20 ms
12,160 KB
testcase_05 AC 6 ms
5,376 KB
testcase_06 AC 19 ms
10,880 KB
testcase_07 AC 14 ms
8,576 KB
testcase_08 AC 13 ms
7,552 KB
testcase_09 AC 21 ms
12,160 KB
testcase_10 AC 28 ms
14,208 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 28 ms
14,080 KB
testcase_14 AC 10 ms
6,528 KB
testcase_15 AC 9 ms
5,504 KB
testcase_16 AC 9 ms
5,504 KB
testcase_17 AC 7 ms
5,376 KB
testcase_18 AC 31 ms
16,128 KB
testcase_19 AC 22 ms
12,416 KB
testcase_20 AC 4 ms
5,376 KB
testcase_21 AC 14 ms
8,448 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 5 ms
5,376 KB
testcase_24 AC 9 ms
5,632 KB
testcase_25 AC 27 ms
14,208 KB
testcase_26 AC 14 ms
8,448 KB
testcase_27 AC 9 ms
5,632 KB
testcase_28 AC 8 ms
5,376 KB
testcase_29 AC 19 ms
10,368 KB
testcase_30 AC 8 ms
5,504 KB
testcase_31 AC 18 ms
10,240 KB
testcase_32 AC 31 ms
16,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = read_line.to_i
a = read_line.split.map(&.to_i)
ans = 0i64
lo = 0
while lo < n
  hi = lo + 1
  while hi < n && a[hi] - a[lo] == hi - lo
    hi += 1
  end
  len = (hi - lo).to_i64
  ans += len * (len - 1) // 2
  lo = hi
end
puts ans
0