Submission #621988

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
6219882022-08-04 03:25:47DeepessonBoxes with souvenirs (IOI15_boxes)C++17
20 / 100
1 ms256 KiB
#include <bits/stdc++.h>
long long delivery(int N, int K, int L, int p[]);
using ll = long long;
ll inf = 1LL<<60LL;
long long delivery(int N, int K, int L, int p[]) {
ll dp[N+1];
for(auto&x:dp)x=inf;
dp[0]=0;
std::deque<ll> dn,dc;
dn.push_back(0);
dc.push_back(2*L-2*p[0]);
for(int i=0;i!=N;++i){
ll custo_local = std::min((ll)L,(ll)2*p[i]);
dp[i+1]=std::min(dn.front()+custo_local,dc.front());
if(dn.size()==K){
dn.pop_front();
}
if(dc.size()==K){
dc.pop_front();
}
ll custo_push = 2*L-2*p[i+1];
dn.push_back(dp[i+1]);
ll custo_final = dp[i+1]+custo_push;
while(dc.size()&&dc.back()>=custo_final)dc.pop_back();
dc.push_back(custo_final);
}
return dp[N];
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:16:21: warning: comparison of integer expressions of different signedness: 'std::deque<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   16 |         if(dn.size()==K){
      |            ~~~~~~~~~^~~
boxes.cpp:19:21: warning: comparison of integer expressions of different signedness: 'std::deque<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |         if(dc.size()==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...