結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
17,024 KB
testcase_01 AC 11 ms
16,896 KB
testcase_02 AC 111 ms
17,024 KB
testcase_03 AC 102 ms
17,024 KB
testcase_04 AC 102 ms
17,024 KB
testcase_05 AC 105 ms
17,024 KB
testcase_06 AC 93 ms
17,024 KB
testcase_07 AC 94 ms
16,896 KB
testcase_08 AC 29 ms
16,896 KB
testcase_09 AC 56 ms
16,896 KB
testcase_10 AC 60 ms
17,024 KB
testcase_11 AC 74 ms
16,896 KB
testcase_12 AC 50 ms
16,896 KB
testcase_13 AC 11 ms
16,896 KB
testcase_14 AC 81 ms
16,896 KB
testcase_15 AC 11 ms
16,896 KB
testcase_16 AC 98 ms
16,896 KB
testcase_17 AC 24 ms
17,024 KB
testcase_18 AC 20 ms
16,896 KB
testcase_19 AC 11 ms
17,024 KB
testcase_20 AC 25 ms
17,024 KB
testcase_21 AC 63 ms
17,024 KB
testcase_22 AC 11 ms
17,024 KB
testcase_23 AC 69 ms
17,024 KB
testcase_24 AC 11 ms
17,024 KB
testcase_25 AC 11 ms
16,896 KB
testcase_26 AC 11 ms
16,896 KB
testcase_27 AC 93 ms
16,896 KB
testcase_28 AC 54 ms
17,024 KB
testcase_29 AC 11 ms
16,896 KB
testcase_30 AC 14 ms
17,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#include <unistd.h>
#include <sys/mman.h>

#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=(char const*)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