結果

問題 No.2248 max(C)-min(C)
ユーザー tailstails
提出日時 2023-03-18 02:21:32
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 17 ms / 3,000 ms
コード長 1,527 bytes
コンパイル時間 764 ms
コンパイル使用メモリ 28,000 KB
実行使用メモリ 11,276 KB
最終ジャッジ日時 2023-10-18 16:58:49
合計ジャッジ時間 3,320 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 0 ms
4,348 KB
testcase_07 AC 0 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 0 ms
4,348 KB
testcase_17 AC 0 ms
4,348 KB
testcase_18 AC 14 ms
9,996 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 AC 16 ms
11,276 KB
testcase_21 AC 15 ms
10,764 KB
testcase_22 AC 10 ms
8,488 KB
testcase_23 AC 7 ms
5,520 KB
testcase_24 AC 3 ms
4,528 KB
testcase_25 AC 13 ms
10,332 KB
testcase_26 AC 11 ms
9,296 KB
testcase_27 AC 14 ms
10,248 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 12 ms
9,588 KB
testcase_30 AC 6 ms
5,188 KB
testcase_31 AC 16 ms
11,276 KB
testcase_32 AC 4 ms
4,624 KB
testcase_33 AC 5 ms
5,084 KB
testcase_34 AC 17 ms
11,276 KB
testcase_35 AC 17 ms
11,276 KB
testcase_36 AC 16 ms
11,276 KB
testcase_37 AC 8 ms
7,940 KB
testcase_38 AC 15 ms
10,512 KB
testcase_39 AC 15 ms
10,512 KB
testcase_40 AC 15 ms
10,512 KB
testcase_41 AC 12 ms
9,148 KB
testcase_42 AC 16 ms
10,512 KB
testcase_43 AC 13 ms
9,432 KB
testcase_44 AC 15 ms
10,512 KB
testcase_45 AC 10 ms
8,424 KB
testcase_46 AC 6 ms
5,148 KB
testcase_47 AC 15 ms
10,512 KB
testcase_48 AC 14 ms
10,040 KB
testcase_49 AC 15 ms
11,212 KB
testcase_50 AC 15 ms
11,212 KB
testcase_51 AC 15 ms
11,212 KB
testcase_52 AC 16 ms
11,212 KB
testcase_53 AC 3 ms
4,512 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:59: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
    7 | #define wt1(v) ({char wbuf[64],*wp=wbuf+sizeof wbuf;wt(v);write(1,wp,wbuf+sizeof wbuf-wp);})
      |                                                           ^~~~~
main.c:84:33: note: in expansion of macro ‘wt1’
   84 |                                 wt1(z);
      |                                 ^~~
main.c:85:33: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
   85 |                                 _exit(0);
      |                                 ^~~~~
main.c:85:33: warning: incompatible implicit declaration of built-in function ‘_exit’ [-Wbuiltin-declaration-mismatch]

ソースコード

diff #

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

#define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define wt(v) ({unsigned _z=v;do*--wp=_z%10+48;while(_z/=10);})
#define wt1(v) ({char wbuf[64],*wp=wbuf+sizeof wbuf;wt(v);write(1,wp,wbuf+sizeof wbuf-wp);})
#define rep(v,e) for(typeof(e) v=0;v<e;++v)
#define chmin(v,a) (v=v<=a?v:a)
#define chmax(v,a) (v=v>=a?v:a)

typedef unsigned long ulong;

void sort_aux(ulong*a,ulong*b,int n,int p){
	int c[1024];
	for(int i=0;i<1024;++i){
		c[i]=0;
	}
	for(int i=0;i<n;++i){
		++c[a[i]&1023];
	}
	int t=0;
	for(int i=0;i<1024;++i){
		int u=c[i];
		c[i]=t;
		t+=u;
	}
	if(p==0){
		for(int i=0;i<n;++i){
			b[c[a[i]&1023]++]=a[i]>>10|a[i]<<54;
		}
	}
	if(p==1){
		for(int i=0;i<n;++i){
			b[c[a[i]&1023]++]=a[i]>>44|a[i]<<20;
		}
	}
}

void sort(ulong*a,int n){
	ulong*b=a+n;
	sort_aux(a,b,n,0);
	sort_aux(b,a,n,0);
	sort_aux(a,b,n,1);
}

ulong a[400001*2];

int main(){
	int n;
	unsigned l,m;
	{
		rd_init();
		n=rd();
		rep(i,n){
			a[i*2]=rd();
		}
		l=1<<30;
		m=0;
		rep(i,n){
			unsigned x=a[i*2];
			unsigned y=rd();
			if(x>y){
				unsigned t=x;
				x=y;
				y=t;
			}
			unsigned z=x+y>>1;
			a[i*2+0]=(ulong)z<<32|x;
			a[i*2+1]=(ulong)y<<32|z;
			chmin(l,y);
			chmax(m,x);
		}
	}
	a[n*2]=l;
	sort(a,n*2+1);
	{
		unsigned z=m;
		for(int i=n*2+1;;++i){
			unsigned x=a[i];
			unsigned y=a[i]>>32;
			chmin(z,m-x);
			if(x>=l){
				wt1(z);
				_exit(0);
			}
			chmax(m,y);
		}
	}
}
0