Submission #1061155

#TimeUsernameProblemLanguageResultExecution timeMemory
1061155codefoxBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "boxes.h" using namespace std; #define int long long int delivery(int N,int K,int L,int positions[]) { deque<int> first; deque<int> second; for (int i = 0;i < N; i++) { if (positions[i]==0) continue; if (positions[i]<=L/2) first.push_back(positions[i]); else second.push_front(positions[i]); } int sol = 0; while (first.size() >= K) { int t = K; sol += first[K-1]*2; while (t--) first.pop_front(); } while (second.size() >= K) { int t = K; sol += (L-second[second.size()-K])*2; while (t--) second.pop_back(); } if (first.size()==0 && second.size()==0) return sol; if (first.size() == 0) return sol+(L-second[0])*2; if (second.size()==0) return sol+first.back()*2; int mn = 1e18; if (first.size()+second.size()<=K) mn = L; else { mn = min(mn, L+2*first[first.size()+second.size()-K]); mn = min(mn, L+2*second[second.size()-(first.size()+second.size()-K)]); } mn = min(mn, 2*(first.back()+L-second.front())); return sol+mn; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(long long int, long long int, long long int, long long int*)':
boxes.cpp:19:25: warning: comparison of integer expressions of different signedness: 'std::deque<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   19 |     while (first.size() >= K)
      |            ~~~~~~~~~~~~~^~~~
boxes.cpp:25:26: warning: comparison of integer expressions of different signedness: 'std::deque<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   25 |     while (second.size() >= K)
      |            ~~~~~~~~~~~~~~^~~~
boxes.cpp:35:35: warning: comparison of integer expressions of different signedness: 'std::deque<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   35 |     if (first.size()+second.size()<=K) mn = L;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/bin/ld: /tmp/ccX6S8ye.o: in function `main':
grader.c:(.text.startup+0x1ef): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status