Submission #285955

#TimeUsernameProblemLanguageResultExecution timeMemory
285955OzyBoxes with souvenirs (IOI15_boxes)C++17
50 / 100
2058 ms22020 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i = (a); i <= (b); i++) vector<int> izq,der,arr; long long int costo(vector<int> V,int pos, int K) { long long int cont,res; cont = 0; res = 0; while (pos >= K && pos < V.size()){ res += 2 * V[pos]; pos -= K; } if (pos < V.size()) res += 2 * V[pos]; return res; } long long delivery(int N, int K, int L, int p[]) { long long int mitad,a,ini,fin,b,cont,Ma,Mb; long long int res,MIN,sum,l; res = 0; mitad = L/2; izq.clear(); der.clear(); arr.clear(); rep(i,0,N-1) { if (p[i] <= mitad) izq.push_back(p[i]); else der.push_back(L - p[i]); } if (!izq.empty()) sort(izq.begin(),izq.end()); if (!der.empty()) sort(der.begin(),der.end()); MIN = costo(der,der.size()-1,K) + costo(izq,izq.size()-1,K); rep(i,0,K) { a = L + costo(der,der.size()-1-i,K) + costo(izq, izq.size()-1-(K-i) ,K); MIN = min(MIN,a); } cerr << MIN; return MIN; }

Compilation message (stderr)

boxes.cpp: In function 'long long int costo(std::vector<int>, int, int)':
boxes.cpp:15:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     while (pos >= K && pos < V.size()){
      |                        ~~~~^~~~~~~~~~
boxes.cpp:19:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     if (pos < V.size()) res += 2 * V[pos];
      |         ~~~~^~~~~~~~~~
boxes.cpp:10:19: warning: variable 'cont' set but not used [-Wunused-but-set-variable]
   10 |     long long int cont,res;
      |                   ^~~~
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:41:31: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   41 |     MIN = costo(der,der.size()-1,K) + costo(izq,izq.size()-1,K);
      |                     ~~~~~~~~~~^~
boxes.cpp:41:59: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   41 |     MIN = costo(der,der.size()-1,K) + costo(izq,izq.size()-1,K);
      |                                                 ~~~~~~~~~~^~
boxes.cpp:45:39: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   45 |         a = L + costo(der,der.size()-1-i,K) + costo(izq, izq.size()-1-(K-i) ,K);
      |                           ~~~~~~~~~~~~^~
boxes.cpp:45:70: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   45 |         a = L + costo(der,der.size()-1-i,K) + costo(izq, izq.size()-1-(K-i) ,K);
      |                                                          ~~~~~~~~~~~~^~~~~~
boxes.cpp:25:27: warning: unused variable 'ini' [-Wunused-variable]
   25 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                           ^~~
boxes.cpp:25:31: warning: unused variable 'fin' [-Wunused-variable]
   25 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                               ^~~
boxes.cpp:25:35: warning: unused variable 'b' [-Wunused-variable]
   25 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                                   ^
boxes.cpp:25:37: warning: unused variable 'cont' [-Wunused-variable]
   25 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                                     ^~~~
boxes.cpp:25:42: warning: unused variable 'Ma' [-Wunused-variable]
   25 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                                          ^~
boxes.cpp:25:45: warning: unused variable 'Mb' [-Wunused-variable]
   25 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                                             ^~
boxes.cpp:26:19: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   26 |     long long int res,MIN,sum,l;
      |                   ^~~
boxes.cpp:26:27: warning: unused variable 'sum' [-Wunused-variable]
   26 |     long long int res,MIN,sum,l;
      |                           ^~~
boxes.cpp:26:31: warning: unused variable 'l' [-Wunused-variable]
   26 |     long long int res,MIN,sum,l;
      |                               ^
#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...