Submission #282279

#TimeUsernameProblemLanguageResultExecution timeMemory
282279tinjyuBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
558 ms294008 KiB
#include "boxes.h" #include <iostream> long long int n,k,l,sum[10000005][2]; using namespace std; long long delivery(int N, int K, int L, int p[]) { n=N; k=K; l=L; int mid=n; for(int i=0;i<n;i++) { if(l/2<p[i]) { mid=i; break; } } long long tmp=0; for(int i=0;i<mid;i++) { if(i-k>=0)sum[i][0]=sum[i-k][0]+p[i]; else sum[i][0]=p[i]; } tmp=0; for(int i=n-1;i>=mid;i--) { if(i+k<n)sum[i][1]=sum[i+k][1]+(l-p[i]); else sum[i][1]=(l-p[i]); } long long int ans=sum[mid-1][0]*2+sum[mid][1]*2; //cout<<sum[mid-1][0]<<" "<<sum[mid][1]<<" "<<ans<<endl; for(int i=mid-1;i>=mid-k && i>=-1;i--) { tmp=0; if(i>=0)tmp=sum[i][0]*2; if(i+k+1<n)tmp+=sum[i+k+1][1]*2; //cout<<i<<" "<<sum[i][0]<<" "<<i+k+1<<" "<<sum[i+k+1][1]<<endl; tmp+=l; ans=min(tmp,ans); } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:10:10: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   10 |  int mid=n;
      |          ^
boxes.cpp:26:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   26 |  for(int i=n-1;i>=mid;i--)
      |            ~^~
#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...