結果

問題 No.885 アマリクエリ
ユーザー tails
提出日時 2020-09-14 11:00:36
言語 cLay
(20241019-1)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 297 bytes
コンパイル時間 2,430 ms
コンパイル使用メモリ 179,256 KB
実行使用メモリ 16,000 KB
最終ジャッジ日時 2024-07-05 14:03:38
合計ジャッジ時間 3,315 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

map<int,int>a;ll x,s;

void f(){
	if(!a.empty()){
		auto b=a.begin();
		int c=-b->first;
		if(c>=x){
			int d=b->second;
			a.erase(b);
			int e=c%x;
			s+=1ll*d*(e-c);
			f();
			a[-e]+=d;
		}
	}
}

{
	rd(x);
	REP(x){
		rd(x);
		++a[-x];
		s+=x;
	}
	rd(x);
	REP(x){
		rd(x);
		f();
		wt(s);
	}
}
0