Submission #67757

#TimeUsernameProblemLanguageResultExecution timeMemory
67757theknife2001Boxes with souvenirs (IOI15_boxes)C++17
0 / 100
2 ms380 KiB
#include "boxes.h" //#include "grader.cpp" #include <bits/stdc++.h> using namespace std; const int N=1e7+55; long long dp[N][2]; int n; long long delivery(int N, int k, int L, int p[]) { n=N; int x; int temp=0; bool q=0; for(int i=0;i<n;i++) { x=k; while(x--&&i<n) { dp[i][0]=temp+p[i]; i++; } i--; temp+=p[i]+min(p[i],L-p[i]); } temp=0; for(int i=n-1;i>=0;i--) { x=k; while(x--&&i<n) { dp[i][1]=temp+(L-p[i]); i--; } i++; temp+=L-p[i]+min(p[i],L-p[i]); } long long ans=1e18; for(int i=0;i<n;i++) { ans=min(dp[i][0]+(i+1<n?dp[i+1][1]:0)+min(p[i],L-p[i])+(i+1<n?min(p[i+1],L-p[i+1]):0),ans); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:10:48: warning: declaration of 'N' shadows a global declaration [-Wshadow]
 long long delivery(int N, int k, int L, int p[])
                                                ^
boxes.cpp:6:11: note: shadowed declaration is here
 const int N=1e7+55;
           ^
boxes.cpp:15:10: warning: unused variable 'q' [-Wunused-variable]
     bool q=0;
          ^
#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...