Submission #204053

#TimeUsernameProblemLanguageResultExecution timeMemory
204053SegtreeBoxes with souvenirs (IOI15_boxes)C++14
50 / 100
2056 ms14072 KiB
#include"boxes.h" #include<iostream> #include<algorithm> #include<vector> using namespace std; typedef long long ll; #define chmin(a,b) a=min(a,b) #define chmax(a,b) a=max(a,b) #define rep(i,n) for(int i=0;i<n;i++) #define mod 1000000007 #define mad(a,b) a=(a+b)%mod ll delivery(int N,int K,int L,int P[]){ ll ans=1e17; for(int i=0;i+K-1<N;i++){ ll res=L; for(int j=i-1;j>=0;j-=K)res+=P[j]*2; for(int j=i+K;j<N;j+=K)res+=(L-P[j])*2; chmin(ans,res); } for(int i=0;i<=N;i++){ ll res=0; for(int j=i-1;j>=0;j-=K)res+=P[j]*2; for(int j=i;j<N;j+=K)res+=(L-P[j])*2; chmin(ans,res); } return ans; }/* int main(){ int n,k,l,p[110]; cin>>n>>k>>l; rep(i,n){ cin>>p[i]; } cout<<delivery(n,k,l,p)<<endl; }*/
#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...