結果

問題 No.29 パワーアップ
ユーザー tsuishi
提出日時 2021-01-08 13:48:59
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 870 bytes
コンパイル時間 682 ms
コンパイル使用メモリ 31,360 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-15 18:49:50
合計ジャッジ時間 1,546 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>

#define INPUT(str) do{char *p;fgets(str,sizeof(str),stdin);p=strchr(str,'\n');if(p)*p='\0';}while(0)
static char *getinput( char* str );
static char *getinput(char* str) {char c;char *cp;cp=&str[0];c=fgetc(stdin);while( c != EOF ){if((c==' ')||( c=='\n')) break;*cp++=c;c=fgetc(stdin);}*cp='\0';return &str[0];}
#define REP(a,b) for(int a=0;a<(int)(b);++a)
#define INPBUF (4+3)
int	item[100];
// ***********************
int main(void) {
	char str[INPBUF];
	int	query;
	int	val;
	int	ans;
	int	nokori;

	// init
	REP(i,100) item[i] = 0;
	// ready
	INPUT(str); sscanf( str , "%d", &query );
	REP(i,query*3) {
		getinput(str);
		sscanf( str , "%d", &val );
		item[val-1]++;
	}
	// start
	ans = 0;
	nokori = 0;
	REP(i,100) {
		ans += item[i]/2;
		nokori += ( item[i] & 1 );
	}
	ans += nokori / 4;
	printf("%d\n", ans );

	return 0;
}
0