You are viewing a single comment's thread. Return to all comments →
public static void main(String[] args) { try (var br = new BufferedReader(new InputStreamReader(System.in)); var bw = new BufferedWriter(new OutputStreamWriter(System.out))) { int n = Integer.parseInt(br.readLine().trim()); String[] socks = br.readLine().trim().split(" "); int[] sockCounts = new int[101]; for (String sock : socks) { int color = Integer.parseInt(sock); sockCounts[color]++; } int pairs = 0; for (int count : sockCounts) { pairs += count >> 1; } bw.write(String.valueOf(pairs)); bw.newLine(); bw.flush(); } catch (Exception e) { e.printStackTrace(); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Sales by Match
You are viewing a single comment's thread. Return to all comments →