제출 #1359939

#제출 시각아이디문제언어결과실행 시간메모리
1359939NAMINBoxes with souvenirs (IOI15_boxes)C++20
0 / 100
0 ms344 KiB
#include <bits/stdc++.h>
#include "boxes.h"
#define ll long long

using namespace std;

ll delivery(int N, int K, int l, int p[]) {
	ll ans = 0;
	ll L = l;
	deque<ll> dq;
	for(int i=0;i<N;i++)
		dq.push_back(p[i]);
	sort(dq.begin(),dq.end());
	while(dq.size()>=K){
		ll costl = min(L,dq[K-1]*2LL);
		ll costr = min(L,(L-dq[N-K])*2LL);
		if(costl<=costr){
			ans += costl;
			for(int i=0;i<K;i++)
				dq.pop_front();
		}
		else{
			ans += costr;
			for(int i=0;i<K;i++)
				dq.pop_back();
		}
		//cout << ans << ' ' << costl << ' ' << costr << endl;
	}
	if(dq.size()>0)
		ans += min(min(L,dq.back()*2LL),min(L,(L-dq[0])*2LL));
    return ans;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…