結果

問題 No.2008 Super Worker
コンテスト
ユーザー 👑 tails
提出日時 2022-07-16 20:54:38
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,260 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 245 ms
コンパイル使用メモリ 29,040 KB
最終ジャッジ日時 2026-02-22 09:21:55
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c: In function 'main':
main.c:53:17: error: too many arguments to function 'mmap'; expected 0, have 6
   53 |         char*rp=mmap(0l,1l<<25,1,2,0,0ll);
      |                 ^~~~ ~~
main.c:52:14: note: declared here
   52 |         char*mmap();
      |              ^~~~
main.c:71:9: error: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   71 |         write(1,wp,wbuf+sizeof wbuf-wp);
      |         ^~~~~
main.c:72:9: error: implicit declaration of function '_exit' [-Wimplicit-function-declaration]
   72 |         _exit(0);
      |         ^~~~~
main.c:72:9: warning: incompatible implicit declaration of built-in function '_exit' [-Wbuiltin-declaration-mismatch]

ソースコード

diff #
raw source code

#pragma GCC target("avx2")

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

typedef unsigned long ulong;

typedef struct {
	union { ulong i; double f; } u;
	struct { unsigned a,b; } v;
} S;

void radix_sort_aux(S*a,S*b,int n){
	int c[256];
	for(int i=0;i<256;++i){
		c[i]=0;
	}
	for(int i=0;i<n;++i){
		++c[a[i].u.i&255];
	}
	int t=0;
	for(int i=256;i--;){
		int u=c[i];
		c[i]=t;
		t+=u;
	}
	for(int i=0;i<n;++i){
		int j=c[a[i].u.i&255]++;
		b[j].u.i=a[i].u.i>>8|a[i].u.i<<56;
		b[j].v=a[i].v;
	}
}

void radix_sort(S*a,int n){
	static S b[200000];
	radix_sort_aux(a,b,n);
	radix_sort_aux(b,a,n);
	radix_sort_aux(a,b,n);
	radix_sort_aux(b,a,n);
	radix_sort_aux(a,b,n);
	radix_sort_aux(b,a,n);
	radix_sort_aux(a,b,n);
	radix_sort_aux(b,a,n);
}

S a[200000];

#define MD 1000000007

int main(){
	char*mmap();
	char*rp=mmap(0l,1l<<25,1,2,0,0ll);
	long n=rd();
	rep(i,n){
		a[i].v.a=rd();
	}
	rep(i,n){
		a[i].v.b=rd();
		a[i].u.f=(a[i].v.b-1.)/a[i].v.a;
	}
	radix_sort(a,n);
	ulong z=0,x=1;
	rep(i,n){
		z=(z+a[i].v.a*x)%MD;
		x=x*a[i].v.b%MD;
	}

	char wbuf[64],*wp=wbuf+sizeof wbuf;
	wt(z);
	write(1,wp,wbuf+sizeof wbuf-wp);
	_exit(0);
}
0