Submission #291680

#TimeUsernameProblemLanguageResultExecution timeMemory
291680REALITYNBBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
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 , int positionss[]){ vector<int> positions=positionss ; 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 ; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:5:26: error: conversion from 'int*' to non-scalar type 'std::vector<int>' requested
    5 |    vector<int> positions=positionss ;
      |                          ^~~~~~~~~~
boxes.cpp:4:25: warning: unused parameter 'n' [-Wunused-parameter]
    4 | long long  delivery(int n,int k , int l , int positionss[]){
      |                     ~~~~^