Submission #285895

#TimeUsernameProblemLanguageResultExecution timeMemory
285895Ozy선물상자 (IOI15_boxes)C++17
0 / 100
2083 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 delivery(int N, int K, int L, int p[]) { int mitad,a,ini,fin,b,cont; long long int res,MIN,sum; res = 0; mitad = L/2; rep(i,0,N-1) { if (p[i] <= mitad) izq.push_back(p[i]); else der.push_back(-p[i]); } sort(izq.begin(),izq.end()); sort(der.begin(),der.end()); cont = 0; while (izq.size() >= K) { rep(i,1,K-1) cont++; res += 2*(izq[cont]); cont++; } rep(i, cont ,izq.size()-1) arr.push_back(izq[i]); cont = 0; while (der.size() >= K) { rep(i,1,K-1) cont++; a = (L - der[cont]); res += 2*a; cont++; } rep(i, cont, der.size()-1) arr.push_back(-der[i]); sort(arr.begin(), arr.end()); if (arr.size() < K) { a = arr[0]; b = arr[arr.size()-1]; if (a > mitad) res += 2*(L-a); else if (b <= mitad) res += (2*b); else { a = min(a, L-a); b = min(b, L-b); a = min(L,(a+b)); res += a; } } else { res += L; MIN = L; ini = -1; fin = K; rep(i,1,(arr.size()-K)+1) { a == 0; b == 0; if (ini >= 0) a = arr[ini]; if (fin < arr.size()) b = L - arr[fin]; sum = a+b; MIN = min(sum,MIN); } res+=MIN; } return res; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:22:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |     while (izq.size() >= K) {
      |            ~~~~~~~~~~~^~~~
boxes.cpp:4:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(i,a,b) for (int i = (a); i <= (b); i++)
      |                                        ^
boxes.cpp:27:5: note: in expansion of macro 'rep'
   27 |     rep(i, cont ,izq.size()-1) arr.push_back(izq[i]);
      |     ^~~
boxes.cpp:31:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |     while (der.size() >= K) {
      |            ~~~~~~~~~~~^~~~
boxes.cpp:4:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(i,a,b) for (int i = (a); i <= (b); i++)
      |                                        ^
boxes.cpp:37:5: note: in expansion of macro 'rep'
   37 |     rep(i, cont, der.size()-1) arr.push_back(-der[i]);
      |     ^~~
boxes.cpp:40:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |     if (arr.size() < K) {
      |         ~~~~~~~~~~~^~~
boxes.cpp:4:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(i,a,b) for (int i = (a); i <= (b); i++)
      |                                        ^
boxes.cpp:61:9: note: in expansion of macro 'rep'
   61 |         rep(i,1,(arr.size()-K)+1) {
      |         ^~~
boxes.cpp:62:16: warning: statement has no effect [-Wunused-value]
   62 |              a == 0;
      |              ~~^~~~
boxes.cpp:63:16: warning: statement has no effect [-Wunused-value]
   63 |              b == 0;
      |              ~~^~~~
boxes.cpp:66:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |              if (fin < arr.size()) b = L - arr[fin];
      |                  ~~~~^~~~~~~~~~~~
boxes.cpp:68:21: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
   68 |              sum = a+b;
      |                    ~^~
boxes.cpp:68:21: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
#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...