Submission #1223960

#TimeUsernameProblemLanguageResultExecution timeMemory
1223960moondarksideBoxes with souvenirs (IOI15_boxes)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; int getCost(vector<int>& Arr,int SubT,int k){ int cost=0; for(int i=Arr.size()-1-SubT;i>-1;i-=k){ cost+=Arr[i]*2; } return cost; } int getTime(int N,int K, int L, vector<int> Pos){ vector<int> CostR(1,0); vector<int> CostL(1,0); for(int i=0;i<N && Pos[i]<=L/2;i++){ CostR.push_back(Pos[i]); } for(int i=N-1;i>-1 && Pos[i]>L/2;i--){ CostL.push_back(L-Pos[i]); } int minC=10000000000; int minCI=0; for(int loopS=0;loopS<=K;loopS++){ int loopSR=K-loopS; int cost=0; if((int)CostR.size()-1<loopSR){ cost=10000000000; } if((int)CostL.size()-1<loopS){ cost=10000000000; } cost+=CostR[(CostR.size()-loopSR-1)%K]+CostL[(CostL.size()-loopS-1)%K]; if(cost<minC){ minC=cost; minCI=loopS; } } return min(getCost(CostR,0,K)+getCost(CostL,0,K),getCost(CostR,K-minCI,K)+getCost(CostL,minCI,K)+L); }

Compilation message (stderr)

boxes.cpp: In function 'int getTime(int, int, int, std::vector<int>)':
boxes.cpp:26:18: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000000' to '1410065408' [-Woverflow]
   26 |         int minC=10000000000;
      |                  ^~~~~~~~~~~
boxes.cpp:32:30: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000000' to '1410065408' [-Woverflow]
   32 |                         cost=10000000000;
      |                              ^~~~~~~~~~~
boxes.cpp:35:30: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000000' to '1410065408' [-Woverflow]
   35 |                         cost=10000000000;
      |                              ^~~~~~~~~~~
/usr/bin/ld: /tmp/ccAoxizA.o: in function `main':
grader.c:(.text.startup+0x1ec): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status