Submission #393212

#TimeUsernameProblemLanguageResultExecution timeMemory
393212peuchBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms208 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { long long l[N + 100], r[N + 100]; long long n = N; long long k = K; for(int i = 0; i < N; i++){ l[i] = 2 * p[i]; if(i >= k) l[i] += l[i - k]; } r[N + 1] = 0; for(int i = N - 1; i >= 0; i--){ r[i] = 2 * (L - p[i]); if(i + k < N) r[i] += r[i + k]; } long long ans = n * L; for(int i = 0; i < N; i++){ ans = min(ans, l[i] + r[i + 1]); long long aux = L; int left = i - 1; int right = i + k; if(left >= 0) aux += l[left]; if(right < N) aux += r[right]; ans = min(ans, aux); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:23:17: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   23 |   int right = i + k;
      |               ~~^~~
#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...