Submission #89985

# Submission time Handle Problem Language Result Execution time Memory
89985 2018-12-19T13:22:53 Z Retro3014 Boxes with souvenirs (IOI15_boxes) C++17
10 / 100
2 ms 376 KB
#include "boxes.h"
#include <algorithm>

using namespace std;

#define MAX_N 10000000
typedef long long ll;

ll costf[MAX_N+1], coste[MAX_N+1];
ll answer;



long long delivery(int N, int K, int L, int p[]) {
	for(int i=0; i<N; i++){
		costf[i]=2*(ll)p[i]+(i<K?0:costf[i-K]);
	}	
	for(int i=N-1; i>=0; i--){
		coste[i]=(L-p[i])*2+(i>=N-K?0:coste[i+K]);
	}
	answer=min(costf[N-1], coste[0]);
	for(int i=0; i<N-1; i++){
		answer=min(answer, costf[i]+coste[i+1]); 
		if(i+K+1<N){
			answer = min(answer, costf[i]+coste[i+K+1]+(ll)L);
		}
	}
    return answer;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -