結果

問題 No.29 パワーアップ
コンテスト
ユーザー ひゅーら
提出日時 2017-06-19 17:18:17
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 649 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 27,088 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-10-24 21:02:01
合計ジャッジ時間 763 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:5:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~
main.c:12:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |                 scanf("%d", &a);
      |                 ^~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(void){
	int n;
	scanf("%d", &n);
	int items[10];
	for(int i = 0; i < 10; i++){
		items[i] = 0;
	}
	for(int i = 0; i < n*3; i++){
		int a;
		scanf("%d", &a);
		items[a-1]++;
	}
#ifdef DEBUG
for(int i = 0; i < n; i++){
	printf("%d ", items[i]);
	}
	printf("\n");
#endif
	int ans = 0;
	for(int i = 0; i < 10; i++){
		while(items[i] > 1){
			items[i] -= 2;
#ifdef DEBUG
			printf("%d\n", i);
#endif
			ans++;
		}
	}
#ifdef DEBUG
for(int i = 0; i < n; i++){
	printf("%d ", items[i]);
	}
	printf("\n");
	#endif
	int sum = 0;
	for(int i = 0; i < 10; i++){
		sum += items[i];
	}
	ans += sum/4;
	printf("%d\n", ans);
	return 0;
}
0