제출 #259713

#제출 시각아이디문제언어결과실행 시간메모리
259713uacoder123선물상자 (IOI15_boxes)C++14
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef int lli; typedef pair <lli,lli> ii; typedef pair <lli,ii> iii; typedef vector <lli> vi; int arr[10000000],arr1[10000000],ans=0; long long delivery(int N, int K, int L, int p[]) { int n,k,l; n=N; k=K; l=L; for(int i=0;i<n;++i) { arr[i]=p[i]*2+((i-k>=0)?arr[i-k]:0); } for(int i=n-1;i>=0;--i) arr1[i]=(l-p[i])*2+((i+k<=n-1)?arr1[i+k]:0); ans=min(arr[n-1],arr1[0]); for(int i=0;i<n-1;++i) ans=min(ans,arr[i]+arr1[i+1]); for(int i=0;i<=n;++i) ans=min(ans,((i>0)?arr[i-1]:0)+l+((n-i-k>0)?arr1[(n)-(n-k-i)]:0)); 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...