A - センター採点 / AtCoderRegularContest#001
import java.io.*; import java.util.*; public class Main { public static int N; public static String c; public static int max, min; private void Input() { Scanner sc = new Scanner(System.in); N = Integer.parseInt( sc.next() ); c = sc.next(); } private void Solve() { int[] count = new int[4]; max = 0; min = 101; Arrays.fill(count,0); for (int i=0; i<N; ++i) ++count[c.charAt(i)-'1']; for (int i=0; i<4; ++i) { max = Math.max(max,count[i]); min = Math.min(min,count[i]); } } private void Output() { PrintWriter pw = new PrintWriter(System.out); pw.println(max+" "+min); pw.flush(); } public static void main(String[] args) throws Exception { Main instance = new Main(); instance.Input(); instance.Solve(); instance.Output(); } }
全て同じ数字にした時の最大値と最小値を出力。
〜了〜