제출 #619131

#제출 시각아이디문제언어결과실행 시간메모리
619131aminBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
1 ms212 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { long long n=N; long long k=K; long long l=L; sort(p,p+n); long long preo[n]; long long pree[n]; long long ans[n]; long long v=0; for(long i=0;i<n;i++) { if(i>l/2) break; long long sum=0; for(long y=i;y>=0;y-=k) { sum+=p[y]; } ans[i]=sum*2; v+=2*p[i]; } for(long i=n-1;i>=0;i--) { if(p[i]<=l/2) { break; } long long sum=0; for(long y=i;y<n;y+=k) { sum+=(l-p[y]); } ans[i]=sum*2; v+=2*(l-p[i]); } return v; long long h=1e18; long long f=0; for(long long i=0;i<=ceil(n/k);i++) { long long num=n-i*k; long long f=i*l; long long j; j=1e18; if(num<=0) { h=min(h,f); break; } // cout<<num<<endl; // cout<<num<<endl; if(p[n-num]>l/2) { j=min(j,f+ans[n-num]); } for(long y=0;y<num;y++) { // cout<<y<<' '<<i*k+y+1<<endl; f=i*l; if(p[y]>l/2) { break; } if(y+i*k+1==n) { j=min(j,f+ans[y]); break; } if(y+i*k+1>n) { break; } if(p[y+i*k+1]<=l/2) { continue; } f+=ans[y]; f+=ans[i*k+y+1]; j=min(j,f); // cout<<y<<' '<<i*k+y+1<<endl; } //cout<<j<<endl; h=min(h,j); // cout<<j<<endl; } return h; }

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:47:19: warning: conversion from 'long long int' to '__gnu_cxx::__enable_if<true, double>::__type' {aka 'double'} may change value [-Wconversion]
   47 | for(long long i=0;i<=ceil(n/k);i++)
      |                   ^
boxes.cpp:50:11: warning: declaration of 'f' shadows a previous local [-Wshadow]
   50 | long long f=i*l;
      |           ^
boxes.cpp:46:14: note: shadowed declaration is here
   46 |    long long f=0;
      |              ^
boxes.cpp:9:14: warning: unused variable 'preo' [-Wunused-variable]
    9 |    long long preo[n];
      |              ^~~~
boxes.cpp:10:14: warning: unused variable 'pree' [-Wunused-variable]
   10 |    long long pree[n];
      |              ^~~~
boxes.cpp:46:14: warning: unused variable 'f' [-Wunused-variable]
   46 |    long long f=0;
      |              ^
#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...