結果
問題 | No.703 ゴミ拾い Easy |
ユーザー | 👑 kmjp |
提出日時 | 2018-06-16 01:13:41 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,425 bytes |
コンパイル時間 | 1,189 ms |
コンパイル使用メモリ | 152,304 KB |
実行使用メモリ | 17,996 KB |
最終ジャッジ日時 | 2023-09-13 05:40:38 |
合計ジャッジ時間 | 7,533 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
9,520 KB |
testcase_01 | AC | 3 ms
9,744 KB |
testcase_02 | AC | 3 ms
9,756 KB |
testcase_03 | AC | 3 ms
9,484 KB |
testcase_04 | AC | 3 ms
9,568 KB |
testcase_05 | AC | 3 ms
9,564 KB |
testcase_06 | AC | 3 ms
9,588 KB |
testcase_07 | AC | 3 ms
9,652 KB |
testcase_08 | AC | 3 ms
9,576 KB |
testcase_09 | AC | 3 ms
9,620 KB |
testcase_10 | WA | - |
testcase_11 | AC | 3 ms
9,576 KB |
testcase_12 | AC | 2 ms
9,560 KB |
testcase_13 | AC | 3 ms
9,584 KB |
testcase_14 | AC | 3 ms
9,536 KB |
testcase_15 | AC | 3 ms
9,580 KB |
testcase_16 | AC | 3 ms
9,592 KB |
testcase_17 | AC | 3 ms
9,576 KB |
testcase_18 | AC | 3 ms
9,544 KB |
testcase_19 | AC | 3 ms
9,664 KB |
testcase_20 | AC | 3 ms
9,556 KB |
testcase_21 | AC | 3 ms
9,580 KB |
testcase_22 | AC | 3 ms
9,588 KB |
testcase_23 | AC | 3 ms
9,552 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 167 ms
17,672 KB |
testcase_37 | WA | - |
testcase_38 | AC | 169 ms
17,864 KB |
testcase_39 | AC | 170 ms
17,756 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | AC | 3 ms
9,484 KB |
testcase_45 | AC | 3 ms
9,596 KB |
testcase_46 | AC | 161 ms
17,632 KB |
testcase_47 | WA | - |
testcase_48 | AC | 3 ms
9,628 KB |
testcase_49 | AC | 3 ms
9,732 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- template<typename V> struct ConvexHull { deque<pair<V,V>> Q; int cmptype=0; // 0-min 1-max V calc(pair<V,V> p, V x) { return p.first*x+p.second; } int dodo(pair<V,V> A,pair<V,V> B, pair<V,V> C) { // max or min return cmptype^((B.second-C.second)*(B.first-A.first)<=(A.second-B.second)*(C.first-B.first)); } void add(V a, V b) { // add ax+b Q.push_front({a,b}); while(Q.size()>=3 && !dodo(Q[0],Q[1],Q[2])) Q[1]=Q[0], Q.pop_front(); } V query(V x) { int L=-1,R=Q.size()-1; while(R-L>1) { int M=(L+R)/2; ((cmptype^((calc(Q[M],x)>=calc(Q[M+1],x))))?L:R)=M; } return calc(Q[R],x); } }; template<typename V> struct ConvexHull2 { deque<pair<V,V>> Q; int cmptype=1; // 0-max 1-min V calc(pair<V,V> p, V x) { return p.first*x+p.second; } int dodo(pair<V,V> A,pair<V,V> B, pair<V,V> C) { // max or min return cmptype^((B.second-C.second)*(B.first-A.first)<=(A.second-B.second)*(C.first-B.first)); } void add(V a, V b) { // add ax+b Q.push_back({a,b}); int v; while((v=Q.size())>=3 && dodo(Q[v-3],Q[v-2],Q[v-1])) Q[v-2]=Q[v-1], Q.pop_back(); } void add(vector<pair<V,V>> v) { sort(v.begin(),v.end()); if(cmptype==1) reverse(v.begin(),v.end()); for(auto r=v.begin();r!=v.end();r++) add(r->first,r->second); } V query(V x) { int L=-1,R=Q.size()-1; while(R-L>1) { int M=(L+R)/2; (cmptype^((calc(Q[M],x)<=calc(Q[M+1],x)))?L:R)=M; } return calc(Q[R],x); } }; int N; ll A[303030]; ll X[303030]; ll Y[303030]; ll D[303030]; ConvexHull<ll> cht; void solve() { int i,j,k,l,r,x,y; string s; cin>>N; FOR(i,N) cin>>A[i]; FOR(i,N) cin>>X[i]; FOR(i,N) cin>>Y[i]; FOR(i,N) { cht.add(-2*X[i],D[i]+X[i]*X[i]+Y[i]*Y[i]); D[i+1]=cht.query(A[i])+A[i]*A[i]; } cout<<D[N]<<endl; } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); cout.tie(0); solve(); return 0; }