Submission #250245

#TimeUsernameProblemLanguageResultExecution timeMemory
250245PbezzBuilding Bridges (CEOI17_building)C++14
30 / 100
3053 ms4476 KiB
#include <bits/stdc++.h> using namespace std; #define loop(i,n) for (ll i = 0; i < n; i++) #define ll long long #define INF 100000000005 #define MAXN 1000005 #define MOD 1000000000007 #define pb push_back #define mp make_pair typedef pair<ll,ll> pii; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n,i,j,k; scanf("%lld",&n); ll h[n]; ll w[n]; ll dp[n]; ll sum[n]; for(i=0;i<n;i++){ scanf("%lld",&h[i]); } for(i=0;i<n;i++){ scanf("%lld",&w[i]); } sum[0]=w[0]; for(i=1;i<n;i++){ sum[i]=sum[i-1]+w[i]; dp[i]=INF; } dp[0]=0; for(i=1;i<n;i++){ for(j=i-1;j>=0;j--){ k=(h[i]-h[j])*(h[i]-h[j]); k+=dp[j]; k+=(sum[i-1]-sum[j]); dp[i]=min(dp[i],k); } } printf("%lld\n",dp[n-1]); return 0; }

Compilation message (stderr)

building.cpp: In function 'int main()':
building.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
  ~~~~~^~~~~~~~~~~
building.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&h[i]);
  ~~~~~^~~~~~~~~~~~~~
building.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&w[i]);
  ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...