結果

問題 No.1767 BLUE to RED
ユーザー tailstails
提出日時 2021-11-30 16:40:25
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 905 bytes
コンパイル時間 1,273 ms
コンパイル使用メモリ 30,252 KB
実行使用メモリ 6,964 KB
最終ジャッジ日時 2023-09-16 11:15:17
合計ジャッジ時間 4,825 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 0 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 0 ms
4,376 KB
testcase_08 AC 0 ms
4,380 KB
testcase_09 AC 4 ms
4,516 KB
testcase_10 AC 5 ms
5,352 KB
testcase_11 AC 5 ms
4,788 KB
testcase_12 AC 4 ms
4,512 KB
testcase_13 AC 6 ms
5,748 KB
testcase_14 AC 7 ms
6,808 KB
testcase_15 AC 8 ms
6,904 KB
testcase_16 AC 8 ms
6,896 KB
testcase_17 AC 7 ms
6,916 KB
testcase_18 AC 7 ms
6,804 KB
testcase_19 AC 7 ms
6,952 KB
testcase_20 AC 8 ms
6,956 KB
testcase_21 AC 7 ms
6,964 KB
testcase_22 AC 7 ms
6,868 KB
testcase_23 AC 7 ms
6,884 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘f3’ 内:
main.c:55:9: 警告: 関数 ‘write’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   55 |         write(1,wp,wbuf+sizeof wbuf-wp);
      |         ^~~~~
main.c:56:9: 警告: implicit declaration of function ‘_exit’; did you mean ‘_Exit’? [-Wimplicit-function-declaration]
   56 |         _exit(0);
      |         ^~~~~
      |         _Exit
main.c: トップレベル:
main.c:59:1: 警告: 戻り値の型をデフォルトの ‘int’ にします [-Wimplicit-int]
   59 | main(){
      | ^~~~

ソースコード

diff #

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

char*mmap();

#define rd(v) long v=0;{long _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}
#define wt(v) {long _z=v;do*--wp=_z%10+48;while(_z/=10);}
#define rep(v,e) for(long v=0;v<e;++v)
#define min(a,b) (a<=b?a:b)

unsigned a[200001],b[200001];

long f2(long an,long bn){
	long p=(long)-2e9,x=0,y=0;
	long ai=0,bi=0;
	while(ai<an||bi<bn){
		long av=a[ai];
		long bv=b[bi];
		if(av<bv){
			++ai;
			long d=av-p;
			y=x=min(x,y+d);
			p=av;
		}else{
			++bi;
			long d=bv-p;
			y=min(x,y+d);
			x=x+d;
			p=bv;
		}
	}
	return x;
}

long f1(){
	char*rp=mmap(0l,1l<<25,1,2,0,0ll);
	rd(an);
	rd(bn);
	rep(ai,an){
		rd(av);
		a[ai]=av;
	}
	a[an]=1u<<31;
	rep(bi,bn){
		rd(bv);
		b[bi]=bv;
	}
	b[bn]=1u<<31;
	return f2(an,bn);
}

void f3(long x){
	char wbuf[64],*wp=wbuf+sizeof wbuf;
	wt(x);
	write(1,wp,wbuf+sizeof wbuf-wp);
	_exit(0);
}

main(){
	f3(f1());
}
0