Submission #285941

#TimeUsernameProblemLanguageResultExecution timeMemory
285941OzyBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
2 ms384 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) { int cont,res; cont = 0; res = 0; rep(i,0,pos) { cont++; if (cont == K) { res += 2*(V[i]); cont = 0; } } if (cont != 0) 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 delivery(int, int, int, int*)':
boxes.cpp:45:31: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   45 |     MIN = costo(der,der.size()-1,K) + costo(izq,izq.size()-1,K);
      |                     ~~~~~~~~~~^~
boxes.cpp:45:59: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   45 |     MIN = costo(der,der.size()-1,K) + costo(izq,izq.size()-1,K);
      |                                                 ~~~~~~~~~~^~
boxes.cpp:49:39: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   49 |         a = L + costo(der,der.size()-1-i,K) + costo(izq, izq.size()-1-(K-i) ,K);
      |                           ~~~~~~~~~~~~^~
boxes.cpp:49:70: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   49 |         a = L + costo(der,der.size()-1-i,K) + costo(izq, izq.size()-1-(K-i) ,K);
      |                                                          ~~~~~~~~~~~~^~~~~~
boxes.cpp:29:27: warning: unused variable 'ini' [-Wunused-variable]
   29 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                           ^~~
boxes.cpp:29:31: warning: unused variable 'fin' [-Wunused-variable]
   29 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                               ^~~
boxes.cpp:29:35: warning: unused variable 'b' [-Wunused-variable]
   29 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                                   ^
boxes.cpp:29:37: warning: unused variable 'cont' [-Wunused-variable]
   29 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                                     ^~~~
boxes.cpp:29:42: warning: unused variable 'Ma' [-Wunused-variable]
   29 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                                          ^~
boxes.cpp:29:45: warning: unused variable 'Mb' [-Wunused-variable]
   29 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                                             ^~
boxes.cpp:30:19: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   30 |     long long int res,MIN,sum,l;
      |                   ^~~
boxes.cpp:30:27: warning: unused variable 'sum' [-Wunused-variable]
   30 |     long long int res,MIN,sum,l;
      |                           ^~~
boxes.cpp:30:31: warning: unused variable 'l' [-Wunused-variable]
   30 |     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...