Submission #218693

#TimeUsernameProblemLanguageResultExecution timeMemory
218693alexandra_udristoiuBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
500 ms172536 KiB
#include<iostream> #include "boxes.h" using namespace std; static long long d[10000005]; static int v[10000005]; long long delivery(int n, int k, int lg, int p[]) { int i, u; long long sol; for(i = 1; i <= n; i++){ v[i] = p[i - 1]; } for(i = 1; i <= n; i++){ if(v[i] > lg - v[i]){ u = i - 1; break; } if(i <= k){ d[i] = 2 * v[i]; } else{ d[i] = 2 * v[i] + d[i - k]; } } for(i = n; i > u; i--){ if(i + k > n){ d[i] = 2 * (lg - v[i]); } else{ d[i] = 2 * (lg - v[i]) + d[i + k]; } } sol = d[u] + d[u + 1]; for(i = u; i >= 1 && i > u - k; i--){ sol = min(sol, lg + d[i - 1] + d[ min(i + k, n + 1) ]); } return sol; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:7:12: warning: 'u' may be used uninitialized in this function [-Wmaybe-uninitialized]
     int i, u;
            ^
#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...