제출 #291679

#제출 시각아이디문제언어결과실행 시간메모리
291679REALITYNB선물상자 (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define all(a) a.begin(),a.end() using namespace std; long long delivery(int n,int k , int l , vector<int> positions){ vector<int> fh , sh ; for(int& x : positions){ if(x<=l-x){ fh.push_back(x) ; } else sh.push_back(l-x) ; } sort(all(fh)) ; sort(all(sh)) ; long long ans = 0 ; while(fh.size()||sh.size()){ int kk = k ; if(fh.empty()){ if(sh.empty()) break ; while(sh.size()){ ans+=sh.back()*2 ; while(kk--&&sh.size()){ sh.pop_back() ; } } break ; } else if(sh.empty()){ if(fh.empty()) break ; while(fh.size()){ ans+=fh.back()*2 ; while(kk--&&fh.size()){ fh.pop_back() ; } } } if(sh.back()*2+fh.back()*2<=l){ while(fh.size()){ ans+=fh.back()*2 ; while(kk--&&fh.size()){ fh.pop_back() ; } } kk = k ; while(sh.size()){ ans+=sh.back()*2 ; while(kk--&&sh.size()){ sh.pop_back() ; } } break ; } ans+=l ; while(kk--){ if(sh.size()==0&&fh.empty()) break ; if(fh.empty()){ sh.pop_back() ; continue ; } if(sh.empty()){ fh.pop_back() ; continue ; } if(fh.back()<=sh.back()) sh.pop_back() ; else fh.pop_back() ; } } return ans ; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, std::vector<int>)':
boxes.cpp:4:25: warning: unused parameter 'n' [-Wunused-parameter]
    4 | long long  delivery(int n,int k , int l , vector<int> positions){
      |                     ~~~~^
/tmp/cc58xuUU.o: In function `main':
grader.c:(.text.startup+0x1b4): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status