結果

問題 No.2851 Make Pairs
ユーザー Maeda
提出日時 2025-03-19 11:19:32
言語 C
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 412 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 25,472 KB
実行使用メモリ 14,772 KB
最終ジャッジ日時 2025-03-19 11:19:36
合計ジャッジ時間 4,482 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 TLE * 1 -- * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
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:8:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |                 scanf("%d",&card[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

void main(void){
	int n = 0;
	scanf("%d",&n);
	int card[n];
	for(int i = 0; i < n ; i++){
		scanf("%d",&card[i]);
	}
	int count = 0;
	for(int i = 0;i < n;i++ ){
		if(card[i] == -1){
			continue;
		}
		for(int j = i+1 ;j < n;j++){
			if(card[i] == -1){
				continue;
			}
			if(card[i] == card[j]){
				card[i] = -1;
				card[j] = -1;
				count++;
				break;
			}
		}
	}
	printf("%d",count);
}
0