제출 #60724

#제출 시각아이디문제언어결과실행 시간메모리
60724Flugan42선물상자 (IOI15_boxes)C++14
50 / 100
2039 ms12708 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef long double lld;
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define per(i,a,b) for(ll i = a; i >= b; i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)(x).size()
#define trav(a,x) for(auto a : x)
#define inf 1000000000000000000
 
long long delivery(int N, int K, int L, int p[]) {
  ll best = inf,n = N,cur,res;
  vi a;
  rep(i,0,N) {
    if (p[i] == 0) n--;
    else a.push_back(p[i]);
  }
 
  rep(h,0,n+1) rep(v,0,n+1){
    if (h+v > n) break;
    ll l = n-h-v;
    res = ((l+K-1)/K)*L;
    cur = h-1;
    while(cur >= 0){
      res += a[cur]*2;
      cur -= K;
    }
    cur = n-v;
    while (cur < n){
      res += (L-a[cur])*2;
      cur += K;
    }
    best = min(best,res);
  }
 
  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...