結果

問題 No.9009 改行区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー tailstails
提出日時 2023-07-14 11:41:00
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 3,000 ms
コード長 725 bytes
コンパイル時間 1,176 ms
コンパイル使用メモリ 25,460 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-14 00:59:44
合計ジャッジ時間 2,546 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,348 KB
testcase_01 AC 0 ms
4,352 KB
testcase_02 AC 0 ms
4,352 KB
testcase_03 AC 0 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 0 ms
4,352 KB
testcase_06 AC 0 ms
4,348 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 4 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 4 ms
4,348 KB
testcase_13 AC 5 ms
4,352 KB
testcase_14 AC 3 ms
4,352 KB
testcase_15 AC 3 ms
4,352 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 0 ms
4,352 KB
testcase_18 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:11:5: warning: implicit declaration of function ‘read’ [-Wimplicit-function-declaration]
  if(read(0,rbuf,RSIZE)<RSIZE){
     ^~~~
main.c:25:5: warning: implicit declaration of function ‘memcpy’ [-Wimplicit-function-declaration]
     memcpy(rbuf,rp,d);
     ^~~~~~
main.c:25:5: warning: incompatible implicit declaration of built-in function ‘memcpy’
main.c:25:5: note: include ‘<string.h>’ or provide a declaration of ‘memcpy’
main.c:1:1:
+#include <string.h>
 #pragma GCC optimize("Ofast")
main.c:25:5:
     memcpy(rbuf,rp,d);
     ^~~~~~
main.c:44:2: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
  write(1,wp,wbuf+sizeof wbuf-wp);
  ^~~~~
main.c:45:2: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
  _exit(0);
  ^~~~~
main.c:45:2: warning: incompatible implicit declaration of built-in function ‘_exit’

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

typedef unsigned long ulong;

#define RSIZE (1<<19)
char rbuf[RSIZE+1];

int main(){
	int rlast=0;
	if(read(0,rbuf,RSIZE)<RSIZE){
		rlast=1;
	}
	char*rp=rbuf;
	while(*rp++>=48);
	ulong res=0;
	do{
		if(rlast){
			if(!*rp){
				break;
			}
		}else{
			long d=rbuf+RSIZE-rp;
			if(d<24){
				memcpy(rbuf,rp,d);
				rp=rbuf;
				int nr=read(0,rbuf+d,RSIZE-d);
				if(nr==0){
					break;
				}
				if(d+nr!=RSIZE){
					rbuf[d+nr]=0;
					rlast=1;
				}
			}
		}
		ulong a=0;
		for(int c;c=*rp++-48,c>=0;)a=a*10+c;
		res+=a;
	}while(*rp);
	char wbuf[64],*wp=wbuf+sizeof wbuf;
	ulong _z=res;
	do*--wp=_z%10+48;while(_z/=10);
	write(1,wp,wbuf+sizeof wbuf-wp);
	_exit(0);
}
0