結果

問題 No.1515 Making Many Multiples
ユーザー tailstails
提出日時 2021-05-24 20:31:24
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 972 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 36,120 KB
実行使用メモリ 17,024 KB
最終ジャッジ日時 2024-04-21 06:12:27
合計ジャッジ時間 2,849 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
17,024 KB
testcase_01 AC 12 ms
17,024 KB
testcase_02 AC 112 ms
17,024 KB
testcase_03 AC 113 ms
17,024 KB
testcase_04 AC 111 ms
17,024 KB
testcase_05 AC 118 ms
16,896 KB
testcase_06 AC 97 ms
17,024 KB
testcase_07 AC 102 ms
17,024 KB
testcase_08 AC 31 ms
16,896 KB
testcase_09 AC 58 ms
17,024 KB
testcase_10 AC 60 ms
17,024 KB
testcase_11 AC 77 ms
16,896 KB
testcase_12 AC 51 ms
17,024 KB
testcase_13 AC 12 ms
17,024 KB
testcase_14 AC 90 ms
17,024 KB
testcase_15 AC 12 ms
17,024 KB
testcase_16 AC 99 ms
16,896 KB
testcase_17 AC 28 ms
17,024 KB
testcase_18 AC 21 ms
17,024 KB
testcase_19 AC 13 ms
16,896 KB
testcase_20 AC 26 ms
16,896 KB
testcase_21 AC 67 ms
16,896 KB
testcase_22 AC 12 ms
17,024 KB
testcase_23 AC 80 ms
16,896 KB
testcase_24 AC 11 ms
16,896 KB
testcase_25 AC 12 ms
17,024 KB
testcase_26 AC 12 ms
16,896 KB
testcase_27 AC 96 ms
17,024 KB
testcase_28 AC 56 ms
16,896 KB
testcase_29 AC 12 ms
16,896 KB
testcase_30 AC 16 ms
17,024 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:62:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   62 |         write(1,wp,wbuf+sizeof wbuf-wp);
      |         ^~~~~
main.c:63:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   63 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

diff #

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

void*mmap();
#define rd_skip() while(*rp++>=48)
#define rd(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}

#define wt_rev(v) {long _z=v;do*--wp=_z%10+48;while(_z/=10);}

#define rep(v,e) for(int v=0;v<e;++v)
#define chmax(v,a) (v=v>=a?v:a)

int dp[2000][2000];
int mx[2000];

int main(){
	rep(i,2000){
		mx[i]=-1<<24;
		rep(j,2000){
			dp[i][j]=-1<<24;
		}
	}

	char const * rp=mmap(0l,1l<<24,1,2,0,0ll);
	rd_skip();
	rd(k);
	rd(x); x%=k;
	rd(y); y%=k;
	
	dp[x][y]=0;
	dp[y][x]=0;
	mx[x]=0;
	mx[y]=0;

	while(*rp){
		rd(a); a%=k;

		int j=-a;
		rep(i,k){
			j+=j<0?k:0;
			int t=dp[i][j]+=1;
			chmax(mx[i],t);
			chmax(mx[j],t);
			j-=1;
		}
		rep(i,k){
			int t=mx[i];
			chmax(dp[i][a],t);
			chmax(dp[a][i],t);
		}
		rep(i,k){
			chmax(mx[a],mx[i]);
		}
	}

	int res=0;
	rep(i,k){
		chmax(res,mx[i]);
	}
	char wbuf[64],*wp=wbuf+sizeof wbuf;
	wt_rev(res);
	write(1,wp,wbuf+sizeof wbuf-wp);
	_exit(0);
}
0