結果

問題 No.2221 Set X
ユーザー tailstails
提出日時 2023-02-21 18:34:47
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 189 ms / 2,000 ms
コード長 853 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 25,696 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-22 04:25:49
合計ジャッジ時間 5,272 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:52:17: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
   52 |                 write(1,wp,wbuf+sizeof wbuf-wp);
      |                 ^~~~~
main.c:54:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
   54 |         _exit(0);
      |         ^~~~~
main.c:54:9: warning: incompatible implicit declaration of built-in function ‘_exit’ [-Wbuiltin-declaration-mismatch]

ソースコード

diff #

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

#define getrp() ({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#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;

int a[100000];
int lf;
int x;

void f(long l,long r){
	int ar=a[r]/x;
	while(lf&&a[l]/x!=ar){
		if(l+1==r){
			--lf;
			break;
		}
		f(l,l+r>>1);
		l=l+r>>1;
	}
}

int main(){
	int bx=0;
	int bf=200000;
	{
		char*rp=getrp();
		long n=rd();
		rep(i,n){
			a[i]=rd();
		}
		for(x=1;x<n*2;++x){
			int o=(bf+x)/(x+1);
			lf=o-1;
			f(0,n-1);
			if(lf>0){
				bf=(o-lf)*(x+1);
				bx=x;
			}
		}
	}
	{
		char wbuf[64],*wp=wbuf+sizeof wbuf;
		*--wp='\n';
		wt(bf);
		*--wp='\n';
		wt(bx);
		write(1,wp,wbuf+sizeof wbuf-wp);
	}
	_exit(0);
}
0