結果
| 問題 | No.29 パワーアップ | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-09-17 11:22:56 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 637 bytes | 
| コンパイル時間 | 1,079 ms | 
| コンパイル使用メモリ | 163,096 KB | 
| 実行使用メモリ | 7,716 KB | 
| 最終ジャッジ日時 | 2025-10-24 21:21:11 | 
| 合計ジャッジ時間 | 1,802 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 22 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |   scanf("%d",&N);
      |   ~~~~~^~~~~~~~~
main.cpp:18:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |     scanf("%d",&k);
      |     ~~~~~^~~~~~~~~
            
            ソースコード
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int N;
int A[1000];
int main(){
  int i, k;
  int res = 0;
  scanf("%d",&N);
  rep(i,3*N){
      // n * 3回分のアイテムを取得
      // アイテムの値を住所にし、そこに値を追加
    scanf("%d",&k);
    A[k]++;
  }
  k = 0;
  rep(i,1000){
    //   アイテムの位置で割る2し、重複分を計算
    res += A[i]/2;
    // 重複していないアイテムを集める
    k += A[i]%2;
  }
  // 任意の4つでレベルを上げる
  res += k / 4;
  printf("%d\n",res);
  return 0;
}
            
            
            
        