Submission #310388

#TimeUsernameProblemLanguageResultExecution timeMemory
310388pedroslreyBuilding Bridges (CEOI17_building)C++14
30 / 100
3044 ms3704 KiB
#include <bits/stdc++.h> using namespace std; using lli = long long int; const int MAXN = 1e5 + 10; const lli INF = 1e18 + 19; lli xs[MAXN]; lli wpref[MAXN]; lli dp[MAXN]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%lld", &xs[i]); for (int i = 1; i <= n; ++i) { scanf("%lld", &wpref[i]); wpref[i] += wpref[i - 1]; } for (int i = 2; i <= n; ++i) { dp[i] = INF; for (int j = 1; j < i; ++j) dp[i] = min(dp[i], dp[j] + wpref[i - 1] - wpref[j] + (xs[j] - xs[i])*(xs[j] - xs[i])); } printf("%lld\n", dp[n]); }

Compilation message (stderr)

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