結果

問題 No.29 パワーアップ
コンテスト
ユーザー nukosuke
提出日時 2016-10-17 23:19:43
言語 C90
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 465 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 186 ms
コンパイル使用メモリ 30,412 KB
最終ジャッジ日時 2026-02-23 22:36:40
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |   scanf("%d", &N);
      |   ^~~~~~~~~~~~~~~
main.c:13:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     scanf("%d %d %d", &a, &b, &c);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <stdio.h>

int main(void) {
  int item[10] = {0,0,0,0,0,0,0,0,0,0};
  int lv = 0;

  int N;
  scanf("%d", &N);

  int a, b, c;
  int i;
  for (i = 0; i < N; i++) {
    scanf("%d %d %d", &a, &b, &c);
    item[a-1]++;
    item[b-1]++;
    item[c-1]++;
  }

  for (i = 0; i < 10; i++) {
    lv += item[i] / 2;
    item[i] %= 2;
  }

  int rest = 0;
  for (i = 0; i < 10; i++) {
    rest += item[i];
  }
  lv += rest / 4;

  printf("%d\n", lv);

  return 0;
}
0