Submission #404737

#TimeUsernameProblemLanguageResultExecution timeMemory
404737DaktoBoxes with souvenirs (IOI15_boxes)C++17
20 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; long long delivery(int n, int k, int l, int V[]){ vector<long long> v(V, V+n); v.erase(v.begin(),lower_bound(v.begin(),v.end(),1)); n=v.size(); vector<long long> ps, ps2(n); long long c=0; for(int i=0; i<n; i++){ ps.push_back(min(2*v[i], (long long)l)+c); if((i+1)%k==0){ c+=min(2*v[i],(long long)l); } } c=0; int j=0; for(int i=n-1; i>=0; i--,j++){ ps2[i]=min(2*(l-v[i]), (long long)l)+c; if((j+1)%k==0){ c+=min(2*(l-v[i]),(long long)l); } } long long res=min(ps[n-1],ps2[0]); if(k>=n) res=min(res,(long long)l); for(int i=0; i<n-1; i++) res=min(res,ps[i]+ps2[i+1]); for(int i=0; i<n-k-1; i++) res=min(res,ps[i]+ps2[i+k+1]+l); return res; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:8:13: warning: conversion from 'std::vector<long long int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
    8 |     n=v.size();
      |       ~~~~~~^~
#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...