結果

問題 No.703 ゴミ拾い Easy
ユーザー chocoruskchocorusk
提出日時 2018-11-09 10:07:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 262 ms / 1,500 ms
コード長 1,233 bytes
コンパイル時間 1,858 ms
コンパイル使用メモリ 97,656 KB
実行使用メモリ 10,576 KB
最終ジャッジ日時 2023-08-30 19:02:54
合計ジャッジ時間 8,841 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,480 KB
testcase_01 AC 2 ms
7,656 KB
testcase_02 AC 2 ms
7,440 KB
testcase_03 AC 3 ms
7,444 KB
testcase_04 AC 2 ms
7,404 KB
testcase_05 AC 2 ms
7,404 KB
testcase_06 AC 3 ms
7,392 KB
testcase_07 AC 2 ms
7,420 KB
testcase_08 AC 3 ms
7,428 KB
testcase_09 AC 2 ms
7,532 KB
testcase_10 AC 2 ms
7,396 KB
testcase_11 AC 2 ms
7,392 KB
testcase_12 AC 2 ms
7,520 KB
testcase_13 AC 3 ms
7,440 KB
testcase_14 AC 3 ms
7,424 KB
testcase_15 AC 3 ms
7,412 KB
testcase_16 AC 4 ms
7,412 KB
testcase_17 AC 3 ms
7,412 KB
testcase_18 AC 3 ms
7,464 KB
testcase_19 AC 3 ms
7,528 KB
testcase_20 AC 3 ms
7,448 KB
testcase_21 AC 4 ms
7,448 KB
testcase_22 AC 3 ms
7,680 KB
testcase_23 AC 3 ms
7,548 KB
testcase_24 AC 239 ms
10,364 KB
testcase_25 AC 240 ms
10,464 KB
testcase_26 AC 241 ms
10,308 KB
testcase_27 AC 239 ms
10,336 KB
testcase_28 AC 240 ms
10,372 KB
testcase_29 AC 240 ms
10,344 KB
testcase_30 AC 239 ms
10,332 KB
testcase_31 AC 241 ms
10,468 KB
testcase_32 AC 240 ms
10,308 KB
testcase_33 AC 239 ms
10,336 KB
testcase_34 AC 194 ms
10,468 KB
testcase_35 AC 197 ms
10,328 KB
testcase_36 AC 195 ms
10,328 KB
testcase_37 AC 196 ms
10,360 KB
testcase_38 AC 196 ms
10,376 KB
testcase_39 AC 196 ms
10,324 KB
testcase_40 AC 194 ms
10,468 KB
testcase_41 AC 198 ms
10,464 KB
testcase_42 AC 194 ms
10,324 KB
testcase_43 AC 194 ms
10,368 KB
testcase_44 AC 2 ms
7,432 KB
testcase_45 AC 3 ms
7,420 KB
testcase_46 AC 262 ms
10,576 KB
testcase_47 AC 245 ms
10,332 KB
testcase_48 AC 3 ms
7,660 KB
testcase_49 AC 3 ms
7,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main()
{
	int n;
	cin>>n;
	ll a[300001], x[300001], y[300001];
	for(int i=1; i<=n; i++) cin>>a[i];
	for(int i=1; i<=n; i++) cin>>x[i];
	for(int i=1; i<=n; i++) cin>>y[i];
	deque<P> line;
	ll dp=0;
	for(int i=1; i<=n; i++){
		ll a0=-2*x[i], b0=x[i]*x[i]+y[i]*y[i]+dp;
		if(!(line.size()>=1 && line.back().first==a0 && line.back().second<=b0)){
			while(line.size()>1){
				ll a1=line[line.size()-1].first, b1=line[line.size()-1].second;
				ll a2=line[line.size()-2].first, b2=line[line.size()-2].second;
				if((b1-b2)*(a1-a0)<(b0-b1)*(a2-a1)) break;
				line.pop_back();
			}
			line.push_back(P(a0, b0));
		}
		while(line.size()>1){
			ll a1=line[0].first, b1=line[0].second;
			ll a2=line[1].first, b2=line[1].second;
			if(a1*a[i]+b1<a2*a[i]+b2) break;
			line.pop_front();
		}
		ll a1=line[0].first, b1=line[0].second;
		dp=a1*a[i]+b1+a[i]*a[i];
	}
	cout<<dp<<endl;
	return 0;
}
0