제출 #60692

#제출 시각아이디문제언어결과실행 시간메모리
60692istlemin선물상자 (IOI15_boxes)C++14
50 / 100
2037 ms20080 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i = a; i<int(b);++i) #define all(v) v.begin(),v.end() #define sz(v) v.size() #define trav(a,c) for(auto a: c) typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; ll ceilDiv(ll a,ll b){ return a/b+(a%b!=0); } long long delivery(int N, int K, int L, int p[]) { ll n = N; ll k = K; ll l = L; vi left; vi right; rep(i,0,n){ if(p[i]<=l/2) left.push_back(p[i]); else right.push_back(l-p[i]); } sort(all(left)); sort(all(right)); vi costLeft(left.size()+1); rep(i,0,left.size()){ if(i<k) costLeft[i+1] = left[i]*2; else costLeft[i+1] = left[i]*2 + costLeft[i-k+1]; } vi costRight(right.size()+1); rep(i,0,right.size()){ if(i<k) costRight[i+1] = right[i]*2; else costRight[i+1] = right[i]*2 + costRight[i-k+1]; } ll best = 1e18; rep(i,0,costLeft.size()){ rep(j,0,costRight.size()){ ll curr = costLeft[i]+costRight[j]; curr += ceilDiv(n-i-j,k)*l; best = min(best,curr); } } //cout<<best<<endl; return best; }
#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...