Submission #392461

#TimeUsernameProblemLanguageResultExecution timeMemory
392461my99nBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
1 ms332 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long cwtour[1000100], cwwtour[1000100]; long long delivery(int N, int K, int L, int p[]) { int dis = 0; for (int i = 1; i <= N; i++) cwtour[i] = p[i-1] + cwtour[max(0,i-K)]; for (int i = N; i >= 1; i--) cwwtour[i] = L-p[i-1] + cwwtour[i+K>N?0:i+K]; long long ans = 1e18; for (int i = 1; i <= N; i++) { if (i+1 <= N) ans = min(ans, 2*cwtour[i]+2*cwwtour[i+1]); if (i+K+1 <= N) ans = min(ans, 2*cwtour[i]+2*cwwtour[i+K+1]+L); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:7:7: warning: unused variable 'dis' [-Wunused-variable]
    7 |   int dis = 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...