結果

問題 No.703 ゴミ拾い Easy
ユーザー nxterunxteru
提出日時 2018-11-10 12:08:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 100 ms / 1,500 ms
コード長 696 bytes
コンパイル時間 1,715 ms
コンパイル使用メモリ 165,812 KB
実行使用メモリ 17,624 KB
最終ジャッジ日時 2023-08-30 19:03:29
合計ジャッジ時間 6,202 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
9,800 KB
testcase_01 AC 3 ms
9,636 KB
testcase_02 AC 3 ms
9,604 KB
testcase_03 AC 2 ms
9,636 KB
testcase_04 AC 2 ms
9,680 KB
testcase_05 AC 3 ms
9,696 KB
testcase_06 AC 3 ms
9,656 KB
testcase_07 AC 3 ms
9,752 KB
testcase_08 AC 3 ms
9,688 KB
testcase_09 AC 2 ms
9,652 KB
testcase_10 AC 3 ms
9,660 KB
testcase_11 AC 2 ms
9,624 KB
testcase_12 AC 3 ms
9,604 KB
testcase_13 AC 2 ms
9,612 KB
testcase_14 AC 3 ms
9,660 KB
testcase_15 AC 3 ms
9,624 KB
testcase_16 AC 3 ms
9,608 KB
testcase_17 AC 3 ms
9,660 KB
testcase_18 AC 3 ms
9,616 KB
testcase_19 AC 3 ms
9,632 KB
testcase_20 AC 3 ms
9,644 KB
testcase_21 AC 3 ms
9,664 KB
testcase_22 AC 3 ms
9,604 KB
testcase_23 AC 3 ms
9,632 KB
testcase_24 AC 96 ms
13,460 KB
testcase_25 AC 96 ms
13,492 KB
testcase_26 AC 95 ms
13,480 KB
testcase_27 AC 96 ms
13,448 KB
testcase_28 AC 96 ms
13,436 KB
testcase_29 AC 96 ms
13,600 KB
testcase_30 AC 97 ms
13,420 KB
testcase_31 AC 96 ms
13,420 KB
testcase_32 AC 96 ms
13,460 KB
testcase_33 AC 96 ms
13,464 KB
testcase_34 AC 88 ms
17,604 KB
testcase_35 AC 89 ms
17,520 KB
testcase_36 AC 88 ms
17,572 KB
testcase_37 AC 88 ms
17,624 KB
testcase_38 AC 89 ms
17,556 KB
testcase_39 AC 89 ms
17,600 KB
testcase_40 AC 89 ms
17,588 KB
testcase_41 AC 89 ms
17,560 KB
testcase_42 AC 89 ms
17,572 KB
testcase_43 AC 89 ms
17,552 KB
testcase_44 AC 3 ms
9,656 KB
testcase_45 AC 2 ms
9,656 KB
testcase_46 AC 100 ms
13,520 KB
testcase_47 AC 100 ms
13,620 KB
testcase_48 AC 3 ms
9,640 KB
testcase_49 AC 3 ms
9,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define F first
#define S second
ll n,dp[300005],m[300005],x[300005],y[300005];
P dq[300005];
bool check(P a,P b,P c){return (a.F-b.F)*(b.S-c.S)>=(a.S-b.S)*(b.F-c.F);}
int main(void){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",m+i);
	for(int i=1;i<=n;i++)scanf("%lld",x+i);
	for(int i=1;i<=n;i++)scanf("%lld",y+i);
	ll l=0,r=0;
	for(int i=1;i<=n;i++){
		P p=P(-2*x[i],x[i]*x[i]+y[i]*y[i]+dp[i-1]);
		while(r-2>=l&&check(dq[r-2],dq[r-1],p))r--;
		dq[r++]=p;
		while(l+1<r&&dq[l+1].F*m[i]+dq[l+1].S<=dq[l].F*m[i]+dq[l].S)l++;
		dp[i]=m[i]*m[i]+dq[l].F*m[i]+dq[l].S;
	}
	printf("%lld\n",dp[n]);
}
0