Submission #109615

#TimeUsernameProblemLanguageResultExecution timeMemory
109615Nodir_BobievBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
3 ms384 KiB
# include <iostream> using namespace std; long long delivery( int N, int K, int L, int positions[] ) { long long answer = 0; int cnt = N, jnt = 0; while( cnt > 0 ){ long long l = positions[ jnt ]; jnt += min( cnt, K ); cnt -= min( cnt, K ); long long r = positions[ jnt - 1 ]; long long mnl = min( l, L - l ); long long mnr = min( (L - r), r ); answer += min( L - l + mnl, r + mnr ); } return answer; } /* int main() { int N, K, L, positions[1000]; cin >> N >> K >> L; for ( int i = 0; i < N; i ++ ){ cin >> positions[i]; } cout << delivery( N, K, L, positions ); return 0; } /* 3 2 8 1 2 5 */ /**/

Compilation message (stderr)

boxes.cpp:37:1: warning: "/*" within comment [-Wcomment]
 /*
#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...