Submission #783283

#TimeUsernameProblemLanguageResultExecution timeMemory
783283MatblubeBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
0 ms340 KiB
#include "boxes.h" #include <iostream> #include <iomanip> #include <string> #include <math.h> #include <algorithm> #include <cstring> #include <numeric> #include <vector> #include <map> #include <set> #include <deque> #include <unordered_map> #include <unordered_set> using namespace std; typedef long long ll; #define dbg(x) cerr<<#x<<": "<<x<<"\n"; #define fr(i, x) for(ll i=0 ; i<x ; i++) #define fra(x, v) for(auto x:v) #define fra1(x,v) for(auto &x:v) #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define pb(x) push_back(x) #define F first #define S second const ll maxN=1e6; ll dp[maxN], dp1[maxN]; long long delivery(int N, int K, int L, int p[]) { ll n=N, k=K, l=L; vector<ll>v(n+1); fr(i, n) v[i+1]=p[i]; dp[1]=dp1[n]=0; for(ll i=1; i <=n ; i++) dp[i]+=(min(l, 2*v[i]))+dp[i-1]; for(ll i=n-1 ; i>0 ; i--) dp1[i]+=(min(l, 2*(l-v[i])))+dp1[i+1]; ll ans=1e18; for(ll i=1 ; i<=n ; i++){ if(i==n){ ans=min(ans, dp[i]+dp1[1]); continue; } ans=min(ans, dp[i]+dp1[i+1]); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:30:13: warning: unused variable 'k' [-Wunused-variable]
   30 |     ll n=N, k=K, l=L;
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...