結果

問題 No.2566 美しい整数列
ユーザー tailstails
提出日時 2023-12-14 12:02:54
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 1,161 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 28,032 KB
実行使用メモリ 13,652 KB
最終ジャッジ日時 2023-12-14 12:02:57
合計ジャッジ時間 3,136 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 61 ms
13,268 KB
testcase_05 AC 62 ms
13,652 KB
testcase_06 AC 10 ms
9,812 KB
testcase_07 AC 9 ms
10,068 KB
testcase_08 AC 8 ms
9,940 KB
testcase_09 AC 9 ms
10,068 KB
testcase_10 AC 10 ms
10,068 KB
testcase_11 AC 16 ms
11,604 KB
testcase_12 AC 15 ms
11,732 KB
testcase_13 AC 15 ms
11,604 KB
testcase_14 AC 16 ms
11,604 KB
testcase_15 AC 16 ms
11,604 KB
testcase_16 AC 17 ms
11,604 KB
testcase_17 AC 17 ms
11,988 KB
testcase_18 AC 17 ms
12,116 KB
testcase_19 AC 13 ms
10,324 KB
testcase_20 AC 17 ms
11,604 KB
testcase_21 AC 17 ms
11,860 KB
testcase_22 AC 12 ms
9,940 KB
testcase_23 AC 15 ms
10,964 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:59: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
    8 | #define wt1(v) ({char wbuf[64],*wp=wbuf+sizeof wbuf;wt(v);write(1,wp,wbuf+sizeof wbuf-wp);})
      |                                                           ^~~~~
main.c:63:9: note: in expansion of macro ‘wt1’
   63 |         wt1(g-e);
      |         ^~~
main.c:64:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
   64 |         _exit(0);
      |         ^~~~~
main.c:64:9: warning: incompatible implicit declaration of built-in function ‘_exit’ [-Wbuiltin-declaration-mismatch]

ソースコード

diff #

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

#define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define rd_signed() ({int _s=*rp=='-'&&++rp,_v=rd();_s?-_v:_v;})
#define wt(v) ({ulong _z=v;do*--wp=_z%10+48;while(_z/=10);})
#define wt1(v) ({char wbuf[64],*wp=wbuf+sizeof wbuf;wt(v);write(1,wp,wbuf+sizeof wbuf-wp);})
#define rep(v,e) for(typeof(e) v=0;v<e;++v)
#define chmax(v,a) (v=v>=a?v:a)

typedef unsigned long ulong;

#define HASH_BITS 18
#define HASH_MASK ((1<<HASH_BITS)-1)
long hash[1<<HASH_BITS];

int hash_get(long x){
	int h=x&HASH_MASK;
	while(1){
		if(hash[h]==0){
			hash[h]=x;
			return h;
		}
		if(hash[h]==x){
			return h;
		}
		h=h+1&HASH_MASK;
	}
}

int a[200000];
int b[200000];
long f[1<<HASH_BITS];

int main(){
	rd_init();
	int n=rd();
	int m=rd();
	rep(i,n){
		a[i]=rd_signed();
	}
	rep(i,m){
		b[i]=rd_signed();
	}
	long d=1234;
	long g=0;
	int j=0;
	rep(i,n){
		int c=rd();
		g+=c;
		int h=hash_get(d-a[i]);
		f[h]+=c;
		d+=b[j];
		if(++j==m){
			j=0;
		}
	}
	long e=0;
	rep(h,1<<HASH_BITS){
		chmax(e,f[h]);
	}
	wt1(g-e);
	_exit(0);
}
0