답안 #82018

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
82018 2018-10-28T12:33:00 Z farukkastamonuda 선물상자 (IOI15_boxes) C++14
0 / 100
3 ms 376 KB
#include "boxes.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define li 10000005
#define mp make_pair
#define pb push_back
using namespace std;
int n,k,l,A[li],bas,t,B[li],son;
long long delivery(int N,int K,int L,int positions[]){
	lo int cevap=0;
	n=N,k=K,l=L;
	for(int i=0;i<n;i++) A[i]=positions[i];
	for(int i=0;i<n;i++){
		if(A[i]!=0) B[++t]=A[i];
	}
	bas=1,son=t;
	while(bas<=son){
		//printf("debug->: : %d  %d  \n",bas,son);
		int z1,z2;
		if(bas+k-1>son) z1=B[son];
		else z1=B[bas+k-1];
		if(son-k+1<bas) z2=B[bas];
		else z2=B[son-k+1];
		//cout<<z1;
		//exit(0);
		lo int cst1=z1-B[bas]+min(z1,l-z1)+min(B[bas],l-B[bas]);
		lo int cst2=B[son]-z2+min(z2,l-z2)+min(B[son],l-B[son]);
		//cout<<"ok->> :: :: "<<z1<<"   ::  "<<B[bas]<<' '<<endl;
		//exit(0);
		if(cst1<=cst2){
			bas=min(bas+k-1,n)+1;
			cevap+=cst1;
		} 
		else {son=max(bas-k+1,1)-1;cevap+=cst2;}
	}
	return cevap;
}
//~ int main(){
	//~ scanf("%d %d %d",&n,&k,&l);
	//~ for(int i=0;i<n;i++) scanf("%d",&A[i]);
	//~ int ty=delivery(n,k,l,A);
	//~ printf("%d\n",ty);
	//~ return 0;
//}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 2 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -