Submission #20892

#TimeUsernameProblemLanguageResultExecution timeMemory
20892baneling100Boxes with souvenirs (IOI15_boxes)C++98
100 / 100
426 ms39536 KiB
#include "boxes.h" #include <algorithm> using namespace std; long long Ans; long long delivery(int N, int K, int L, int p[]) { int i, j, half; long long res; half=upper_bound(p,p+N,L/2)-p-1; for(i=half ; i>=0 ; i-=K) Ans+=2*p[i]; for(i=half+1 ; i<N ; i+=K) Ans+=2*(L-p[i]); for(i=0 ; i<K ; i++) { res=L; for(j=half-i-1 ; j>=0 ; j-=K) res+=2*p[j]; for(j=half-i+K ; j<N ; j+=K) res+=2*(L-p[j]); Ans=min(Ans,res); } return Ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:13:34: warning: conversion to 'int' from 'long int' may alter its value [-Wconversion]
     half=upper_bound(p,p+N,L/2)-p-1;
          ~~~~~~~~~~~~~~~~~~~~~~~~^~
#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...