제출 #862066

#제출 시각아이디문제언어결과실행 시간메모리
862066culver0412선물상자 (IOI15_boxes)C++17
20 / 100
1 ms604 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { sort(p,p+N); long long arr[N],brr[N],cursum=0; int cnt=0; for(int i=0;i<N;i++){ if(p[i]==0){ arr[i]=0; continue; } arr[i]=cursum+min(p[i]*2,L); cnt++; if(cnt==K){ cursum+=min(p[i]*2,L); cnt=0; } } cursum=0; cnt=0; for(int i=N-1;i>=0;i--){ if(p[i]==0){ brr[i]=((i==N-1)?(0):(brr[i+1])); continue; } brr[i]=cursum+min((L-p[i])*2,L); cnt++; if(cnt==K){ cursum+=min((L-p[i])*2,L); cnt=0; } } long long ans=min(brr[0],arr[N-1]); //cout << brr[0] << '\n'; for(int i=0;i<N-1;i++){ //cout << arr[i] << ' ' << brr[i+1] << '\n'; ans=min(ans,arr[i]+brr[i+1]); } //cout << arr[N-1] << '\n'; 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...