結果
| 問題 |
No.703 ゴミ拾い Easy
|
| コンテスト | |
| ユーザー |
nxteru
|
| 提出日時 | 2018-11-10 12:08:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 113 ms / 1,500 ms |
| コード長 | 696 bytes |
| コンパイル時間 | 1,717 ms |
| コンパイル使用メモリ | 161,212 KB |
| 実行使用メモリ | 17,820 KB |
| 最終ジャッジ日時 | 2025-01-02 14:05:18 |
| 合計ジャッジ時間 | 6,463 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 46 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%lld",&n);
| ~~~~~^~~~~~~~~~~
main.cpp:12:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | for(int i=1;i<=n;i++)scanf("%lld",m+i);
| ~~~~~^~~~~~~~~~~~
main.cpp:13:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | for(int i=1;i<=n;i++)scanf("%lld",x+i);
| ~~~~~^~~~~~~~~~~~
main.cpp:14:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | for(int i=1;i<=n;i++)scanf("%lld",y+i);
| ~~~~~^~~~~~~~~~~~
ソースコード
#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]);
}
nxteru