제출 #282279

#제출 시각아이디문제언어결과실행 시간메모리
282279tinjyu선물상자 (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; }

컴파일 시 표준 에러 (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...