Submission #450343

#TimeUsernameProblemLanguageResultExecution timeMemory
450343JovanBBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
671 ms386072 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #include "boxes.h" ll niz1[10000005]; ll dp1[10000005]; ll niz2[10000005]; ll dp2[10000005]; ll n; long long delivery(int N, int K, int L, int p[]){ ll l = L; ll k = K; n = N; for(ll i=0; i<N; i++){ if(!p[i]) continue; niz1[i+1] = p[i]; niz2[i+1] = p[i]; } reverse(niz2+1, niz2+n+1); ll cost = 0; ll lcost = 0; for(ll i=n; i>=1; i-=k){ lcost += 2*niz1[i]; } cost = lcost; for(int i=1; i<=n; i++){ if(i-k >= 0) dp1[i] += dp1[i-k]; dp1[i] += 2*niz1[i]; } for(int i=1; i<=n; i++){ if(i-k >= 0) dp2[i] += dp2[i-k]; dp2[i] += 2*(l-niz2[i]); } for(int i=0; i<=n; i++){ int ost = n-k-i; if(ost >= 0) cost = min(cost, l+dp1[i]+dp2[ost]); cost = min(cost, dp1[i]+dp2[n-i]); } return min(cost, lcost); }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:38:22: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   38 |         int ost = n-k-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...