Submission #409759

#TimeUsernameProblemLanguageResultExecution timeMemory
409759radaiosm7Boxes with souvenirs (IOI15_boxes)C++98
100 / 100
583 ms243528 KiB
#include <bits/stdc++.h> using namespace std; #include "boxes.h" long long dp[2][10000005]; int n, i; long long ans; long long delivery(int n, int k, int l, int p[]) { dp[0][0] = 0LL; dp[1][n+1] = 0LL; ans = LONG_LONG_MAX; for (i=1; i <= n; ++i) { dp[0][i] = 0LL; dp[0][i] = dp[0][i-(i-k>=0)*k]+min(2LL*p[i-1], 1LL*l); } for (i=n; i >= 1; --i) { dp[1][i] = 0LL; dp[1][i] = dp[1][i+(i+k<=n)*k]+min(2LL*(l-p[i-1]), 1LL*l); } for (i=0; i <= n; ++i) { ans = min(ans, dp[0][i]+dp[1][i+1]); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:8:24: warning: declaration of 'n' shadows a global declaration [-Wshadow]
    8 | long long delivery(int n, int k, int l, int p[]) {
      |                    ~~~~^
boxes.cpp:5:5: note: shadowed declaration is here
    5 | int n, i;
      |     ^
#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...