結果
問題 | No.1943 消えたAGCT(1) |
ユーザー | eagle |
提出日時 | 2022-05-27 15:50:37 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,033 bytes |
コンパイル時間 | 2,207 ms |
コンパイル使用メモリ | 76,976 KB |
実行使用メモリ | 72,600 KB |
最終ジャッジ日時 | 2023-10-20 19:43:08 |
合計ジャッジ時間 | 7,374 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 132 ms
57,440 KB |
testcase_01 | AC | 130 ms
57,500 KB |
testcase_02 | AC | 133 ms
55,568 KB |
testcase_03 | AC | 131 ms
57,440 KB |
testcase_04 | AC | 132 ms
57,432 KB |
testcase_05 | AC | 130 ms
57,264 KB |
testcase_06 | AC | 132 ms
57,324 KB |
testcase_07 | AC | 133 ms
57,416 KB |
testcase_08 | AC | 129 ms
57,152 KB |
testcase_09 | TLE | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner sc = new Scanner(System.in); //与えられる文字数 int n = sc.nextInt(); //与えられる文字列 String s = sc.next(); //操作の回数 int cnt = 0; while(true) { //文字列sがA,G,C,Tのいずれかを含む場合 if(s.contains("A") || s.contains("G") || s.contains("C") || s.contains("T")) { //A,G,C,Tの文字数を数える変数 int mojisu = 0; for(int i = 0; i < s.length(); i++) { //文字を取り出す char c = s.charAt(i); //取り出した文字がA,G,C,Tのいずれかの場合 if(c == 'A' || c == 'G' || c == 'C' || c == 'T') { //カウントする mojisu++; } } //mojisu文字目を削除した文字列をtに格納する String t = s.substring(0, mojisu - 1) + s.substring(mojisu); s = t; cnt++; } else { break; } } System.out.println(cnt); } }