結果

問題 No.1515 Making Many Multiples
ユーザー tailstails
提出日時 2021-05-24 19:36:49
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 960 bytes
コンパイル時間 1,180 ms
コンパイル使用メモリ 36,412 KB
実行使用メモリ 17,024 KB
最終ジャッジ日時 2024-04-21 05:25:38
合計ジャッジ時間 3,358 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
16,896 KB
testcase_01 AC 6 ms
17,024 KB
testcase_02 AC 84 ms
17,024 KB
testcase_03 AC 87 ms
16,896 KB
testcase_04 AC 84 ms
17,024 KB
testcase_05 AC 84 ms
17,020 KB
testcase_06 AC 70 ms
17,024 KB
testcase_07 AC 77 ms
17,024 KB
testcase_08 AC 21 ms
17,024 KB
testcase_09 AC 43 ms
17,024 KB
testcase_10 AC 45 ms
17,016 KB
testcase_11 AC 61 ms
17,024 KB
testcase_12 AC 40 ms
17,024 KB
testcase_13 AC 6 ms
16,904 KB
testcase_14 AC 61 ms
17,024 KB
testcase_15 AC 6 ms
17,012 KB
testcase_16 AC 77 ms
17,024 KB
testcase_17 AC 20 ms
17,024 KB
testcase_18 AC 13 ms
17,024 KB
testcase_19 AC 7 ms
17,024 KB
testcase_20 AC 16 ms
17,024 KB
testcase_21 AC 51 ms
17,024 KB
testcase_22 AC 8 ms
17,024 KB
testcase_23 AC 54 ms
17,024 KB
testcase_24 AC 5 ms
17,016 KB
testcase_25 AC 5 ms
16,896 KB
testcase_26 AC 6 ms
17,024 KB
testcase_27 AC 74 ms
17,016 KB
testcase_28 AC 43 ms
17,024 KB
testcase_29 AC 7 ms
17,024 KB
testcase_30 AC 9 ms
17,024 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:16:1: warning: return type defaults to 'int' [-Wimplicit-int]
   16 | main(){
      | ^~~~
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")

char*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];

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

	char*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