結果
| 問題 | No.29 パワーアップ |
| コンテスト | |
| ユーザー |
tsuishi
|
| 提出日時 | 2021-01-08 13:48:59 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 870 bytes |
| 記録 | |
| コンパイル時間 | 170 ms |
| コンパイル使用メモリ | 27,852 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-10-24 21:16:47 |
| 合計ジャッジ時間 | 893 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:4:31: warning: ignoring return value of ‘fgets’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
4 | #define INPUT(str) do{char *p;fgets(str,sizeof(str),stdin);p=strchr(str,'\n');if(p)*p='\0';}while(0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:21:9: note: in expansion of macro ‘INPUT’
21 | INPUT(str); sscanf( str , "%d", &query );
| ^~~~~
ソースコード
#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;
}
tsuishi