first commit

This commit is contained in:
Nyagami
2022-12-15 23:51:04 +07:00
commit 87d51fb251
292 changed files with 12623 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package nxt;
import java.util.Scanner;
public class App {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s = sc.next();
int n = s.length();
int[] dpA = new int[n+1];
int[] dpB = new int[n+1];
for(int i=1; i<=n; i++){
if(s.charAt(i-1)=='A'){
dpA[i]=Math.min(dpA[i-1],dpB[i-1]+1);
dpB[i]=Math.min(dpB[i-1]+1, dpA[i-1]+1);
}else{
dpA[i]=Math.min(dpA[i-1]+1,dpB[i-1]+1);
dpB[i]=Math.min(dpB[i-1], dpA[i-1]+1);
}
}
System.out.print(dpA[n]);
sc.close();
}
}