Submission #619080

#TimeUsernameProblemLanguageResultExecution timeMemory
619080aminBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
2 ms212 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { long n=N; long k=K; long l=L; sort(p,p+n); long long preo[n]; long long pree[n]; long long ans[n]; 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; } 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; } long long h=1e9; long long f=0; for(long i=0;i<=ceil(n/k);i++) { long long num=n-i*k; long long f=i*l; long long j; j=1e9; 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(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; }

Compilation message (stderr)

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