結果

問題 No.1943 消えたAGCT(1)
ユーザー simansiman
提出日時 2022-05-21 00:24:10
言語 Ruby
(3.3.0)
結果
AC  
実行時間 654 ms / 2,000 ms
コード長 249 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 11,932 KB
実行使用メモリ 82,944 KB
最終ジャッジ日時 2023-10-20 15:13:21
合計ジャッジ時間 11,566 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
16,084 KB
testcase_01 AC 85 ms
16,084 KB
testcase_02 AC 85 ms
16,084 KB
testcase_03 AC 86 ms
16,084 KB
testcase_04 AC 92 ms
16,084 KB
testcase_05 AC 85 ms
16,084 KB
testcase_06 AC 87 ms
16,084 KB
testcase_07 AC 85 ms
16,084 KB
testcase_08 AC 85 ms
16,084 KB
testcase_09 AC 618 ms
78,008 KB
testcase_10 AC 647 ms
82,944 KB
testcase_11 AC 550 ms
82,940 KB
testcase_12 AC 552 ms
82,940 KB
testcase_13 AC 341 ms
40,552 KB
testcase_14 AC 97 ms
16,964 KB
testcase_15 AC 447 ms
81,912 KB
testcase_16 AC 370 ms
51,396 KB
testcase_17 AC 410 ms
76,516 KB
testcase_18 AC 473 ms
81,892 KB
testcase_19 AC 460 ms
81,864 KB
testcase_20 AC 470 ms
81,932 KB
testcase_21 AC 467 ms
81,908 KB
testcase_22 AC 581 ms
78,360 KB
testcase_23 AC 594 ms
78,364 KB
testcase_24 AC 550 ms
82,940 KB
testcase_25 AC 553 ms
82,940 KB
testcase_26 AC 654 ms
82,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
S = gets.chomp

cnt = S.chars.count { |s| s =~ /[AGCT]/ }
f_idx = S.chars.index { |s| s =~ /[AGCT]/ }
l_idx = S.chars.rindex { |s| s =~ /[AGCT]/ }

if cnt == 0
  puts 0
elsif cnt <= l_idx + 1
  puts l_idx + 1
else
  puts f_idx + 1
end
0