제출 #288704

#제출 시각아이디문제언어결과실행 시간메모리
288704Ozy선물상자 (IOI15_boxes)C++17
10 / 100
1 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; vector<long long int> cizq, cder; long long int costo(vector<long long int> V,int pos, int K) { long long int res; res = 0; if (pos >= 0 && pos < V.size()) return 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(); cizq.clear(); cder.clear(); rep(i,0,N-1) { if (p[i] <= mitad) { izq.push_back(p[i]); if (izq.size() > K) cizq.push_back(2 * p[i] + cizq[izq.size() - K - 1]); else cizq.push_back(2 * p[i]); } else { der.push_back(L - p[i]); if (der.size() > K) cder.push_back(2 * (L - p[i]) + cder[der.size() - K - 1]); else cder.push_back(2 * (L - p[i])); } } if (!der.empty()) { reverse(der.begin(), der.end()); reverse(cder.begin(), cder.end()); } MIN = costo(cder,der.size()-1,K) + costo(cizq,izq.size()-1,K); rep(i,0,K) { a = L + costo(cder,der.size()-1-i,K) + costo(cizq, izq.size()-1-(K-i) ,K); MIN = min(MIN,a); } cerr << MIN; return MIN; }

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

boxes.cpp: In function 'long long int costo(std::vector<long long int>, int, int)':
boxes.cpp:16:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     if (pos >= 0 && pos < V.size()) return V[pos];
      |                     ~~~~^~~~~~~~~~
boxes.cpp:11:58: warning: unused parameter 'K' [-Wunused-parameter]
   11 | long long int costo(vector<long long int> V,int pos, int K) {
      |                                                      ~~~~^
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:36:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |             if (izq.size() > K) cizq.push_back(2 * p[i] + cizq[izq.size() - K - 1]);
      |                 ~~~~~~~~~~~^~~
boxes.cpp:41:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |             if (der.size() > K) cder.push_back(2 * (L - p[i]) + cder[der.size() - K - 1]);
      |                 ~~~~~~~~~~~^~~
boxes.cpp:52:32: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   52 |     MIN = costo(cder,der.size()-1,K) + costo(cizq,izq.size()-1,K);
      |                      ~~~~~~~~~~^~
boxes.cpp:52:61: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   52 |     MIN = costo(cder,der.size()-1,K) + costo(cizq,izq.size()-1,K);
      |                                                   ~~~~~~~~~~^~
boxes.cpp:56:40: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   56 |         a = L + costo(cder,der.size()-1-i,K) + costo(cizq, izq.size()-1-(K-i) ,K);
      |                            ~~~~~~~~~~~~^~
boxes.cpp:56:72: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   56 |         a = L + costo(cder,der.size()-1-i,K) + costo(cizq, izq.size()-1-(K-i) ,K);
      |                                                            ~~~~~~~~~~~~^~~~~~
boxes.cpp:22:27: warning: unused variable 'ini' [-Wunused-variable]
   22 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                           ^~~
boxes.cpp:22:31: warning: unused variable 'fin' [-Wunused-variable]
   22 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                               ^~~
boxes.cpp:22:35: warning: unused variable 'b' [-Wunused-variable]
   22 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                                   ^
boxes.cpp:22:37: warning: unused variable 'cont' [-Wunused-variable]
   22 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                                     ^~~~
boxes.cpp:22:42: warning: unused variable 'Ma' [-Wunused-variable]
   22 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                                          ^~
boxes.cpp:22:45: warning: unused variable 'Mb' [-Wunused-variable]
   22 |     long long int mitad,a,ini,fin,b,cont,Ma,Mb;
      |                                             ^~
boxes.cpp:23:19: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   23 |     long long int res,MIN,sum,l;
      |                   ^~~
boxes.cpp:23:27: warning: unused variable 'sum' [-Wunused-variable]
   23 |     long long int res,MIN,sum,l;
      |                           ^~~
boxes.cpp:23:31: warning: unused variable 'l' [-Wunused-variable]
   23 |     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...