Submission #283501

#TimeUsernameProblemLanguageResultExecution timeMemory
283501FlashGamezzzBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
1 ms256 KiB
#include "boxes.h"

long long delivery(int N, int K, int L, int p[]) {
    long n = N, k = K, l = L;
    long* teams = new long[10000002];
    teams[0] = 0;
    for (long i = 1; i <= n; i++){
	teams[i] = p[i];
    }
    teams[n+1] = l;
	long long ans = 1000000000000000000;
	for (long i = 0; i <= n; i++){
		long long t = 0;
		long j = i, count = 0;
		while (j >= 0){
			if (count == 0){
				t += 2*teams[j];
				count = k;
			}
			j--;
			count--;
		}
		j = i+1;
		count = 0;
		while (j <= n){
			if (count == 0){
				t += 2*(l-teams[j]);
				count = k;
			}
			j++;
			count--;
		}
		if (ans > t){
        	ans = t;
        }
	}
	return ans;
}
#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...