結果
問題 | No.29 パワーアップ |
ユーザー |
![]() |
提出日時 | 2018-04-20 01:06:48 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 146 ms / 5,000 ms |
コード長 | 703 bytes |
コンパイル時間 | 2,223 ms |
コンパイル使用メモリ | 74,428 KB |
実行使用メモリ | 41,896 KB |
最終ジャッジ日時 | 2024-06-27 04:59:21 |
合計ジャッジ時間 | 6,403 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
import java.util.Arrays; import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); // int []a = new int[N]; // int []b = new int[N]; // int []c = new int[N]; int []x = new int[3 *N]; for(int i = 0; i < 3 * N; i++) { x[i] = scan.nextInt(); } scan.close(); Arrays.sort(x); int temp = x[0]; int cnt1 = 1; int cnt2 = 0; int ans = 0; for(int i = 1; i < 3 * N; i++) { if(temp == x[i]) { cnt1 ++; }else { ans += cnt1 / 2; cnt2 += cnt1 % 2; temp = x[i]; cnt1 = 1; } } ans += cnt1 / 2; cnt2 += cnt1 % 2; ans += cnt2 / 4; System.out.println(ans); } }