Submission #101882

#TimeUsernameProblemLanguageResultExecution timeMemory
101882pedro_sponchiadoBoxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; const int maxn=10000010; const long long int INF=112345678912345678; int n, s; long long int l; long long int resp=INF; long long int pos[maxn]; vector<long long int> dist[2]; long long int mini[maxn][2]; long long int aux[maxn][2]; long long int x[maxn]; int main(){ scanf("%d %d %d", &n, &s, &l); for(int i=0; i<n; i++){ scanf("%lld", &pos[i]); if(pos[i]<l/2) dist[0].push_back(pos[i]); if(pos[i]>l/2) dist[1].push_back(l-pos[i]); } //calcula mini for(int k=0; k<=1; k++){ for(int i=0; i<dist[k].size(); i++){ aux[i%s][k]+=dist[k][i]; mini[i+1][k]=aux[i%s][k]; } for(int i=dist[k].size(); i<=n; i++) mini[i+1][k]=INF; } //calcula x for(int i=1; i<=n; i++){ x[i]=INF; for(int k=0; k<=i; k++){ x[i]=min(x[i], mini[k][0]+mini[i-k][1]); } } //calcula resp for(int k=0; k<=n; k++){ if(n-k*s>=0) resp=min(resp, x[n-k*s]+k*l); else resp=min(resp, k*l); } printf("%lld\n", 2*resp); return 0; }

Compilation message (stderr)

boxes.cpp: In function 'int main()':
boxes.cpp:17:30: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
  scanf("%d %d %d", &n, &s, &l);
                            ~~^
boxes.cpp:27:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<dist[k].size(); i++){
                ~^~~~~~~~~~~~~~~
boxes.cpp:31:25: warning: conversion to 'int' from 'std::vector<long long int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
   for(int i=dist[k].size(); i<=n; i++) mini[i+1][k]=INF;
             ~~~~~~~~~~~~^~
boxes.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &s, &l);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
boxes.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &pos[i]);
   ~~~~~^~~~~~~~~~~~~~~~~
/tmp/ccBWEC3v.o: In function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'
/tmp/ccoZdNLv.o:boxes.cpp:(.text.startup+0x0): first defined here
/tmp/ccBWEC3v.o: In function `main':
grader.c:(.text.startup+0x22f): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status