結果

問題 No.29 パワーアップ
ユーザー t8m8⛄️
提出日時 2015-04-03 04:42:07
言語 Java
(openjdk 23)
結果
AC  
実行時間 147 ms / 5,000 ms
コード長 1,067 bytes
コンパイル時間 3,262 ms
コンパイル使用メモリ 78,480 KB
実行使用メモリ 54,408 KB
最終ジャッジ日時 2024-07-04 01:34:00
合計ジャッジ時間 7,073 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

//No.29 パワーアップ

import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class No29 {
    
    static final Scanner sc = new Scanner(System.in);
    static final PrintWriter out = new PrintWriter(System.out,false);

    static void solve() {
        int n = sc.nextInt();
        int[] a = new int[10];
        for (int i=0; i<n; i++) {
            for (int j=0; j<3; j++) {
                a[sc.nextInt()-1]++;
            }
        }
        int cnt = 0, t = 0;
        for (int i=0; i<10; i++) {
            while (a[i] >= 2) {
                a[i] -= 2;
                cnt++;
            }
            t += a[i];
        }
        cnt += t/4;
        out.println(cnt);
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();

        solve();
        out.flush();

        long end = System.currentTimeMillis();
        //trace(end-start + "ms");
        sc.close();
    }

    static void trace(Object... o) { System.out.println(deepToString(o));}
}
0