結果

問題 No.999 てん vs. ほむ
コンテスト
ユーザー 👑 tails
提出日時 2020-10-22 15:24:19
言語 C11(gcc12 gnu拡張)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=gnu11 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 303 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 203 ms
コンパイル使用メモリ 29,380 KB
実行使用メモリ 11,000 KB
最終ジャッジ日時 2026-03-10 23:39:09
合計ジャッジ時間 2,691 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:2:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
    2 | main(){
      | ^~~~
main.c: In function ‘main’:
main.c:6:9: warning: implicit declaration of function ‘read’ [-Wimplicit-function-declaration]
    6 |         read(0,r=rbuf,sizeof rbuf);
      |         ^~~~
main.c:7:12: warning: implicit declaration of function ‘fork’ [-Wimplicit-function-declaration]
    7 |         if(fork()) _exit(0);
      |            ^~~~
main.c:7:20: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
    7 |         if(fork()) _exit(0);
      |                    ^~~~~
main.c:7:20: warning: incompatible implicit declaration of built-in function ‘_exit’ [-Wbuiltin-declaration-mismatch]
main.c:21:9: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
   21 |         printf("%ld",b*2-a);
      |         ^~~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
  +++ |+#include <stdio.h>
    1 | char rbuf[2000000];
main.c:21:9: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
   21 |         printf("%ld",b*2-a);
      |         ^~~~~~
main.c:21:9: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’

ソースコード

diff #
raw source code

char rbuf[2000000];
main(){
	int n,x,y,c;
	long a=0,b=0;
	char*r;
	read(0,r=rbuf,sizeof rbuf);
	if(fork()) _exit(0);
	while(*r++>=48);
	while(*r){
		x=0;
		while(c=*r++,c>=48){
			x=x*10+(c-48);
		}
		y=0;
		while(c=*r++,c>=48){
			y=y*10+(c-48);
		}
		a+=x-y;
		if(b<a) b=a;
	}
	printf("%ld",b*2-a);
}
0