Submission #593603

#TimeUsernameProblemLanguageResultExecution timeMemory
593603PiejanVDCDistributing Candies (IOI21_candies)C++17
Compilation error
0 ms0 KiB
#include "candies.h" #include <bits/stdc++.h> using namespace std; #define int long long vector<int>distribute_candies(vector<int>c, vector<int>l, vector<int>r, vector<int>v) { const int n = (int)c.size(); const int m = (int)l.size(); vector<int>value(m+5); value[0] = 0; for(int i = 1 ; i <= m ; i++) value[i] = value[i-1] + v[i-1]; vector<int>suff_max(m+1), suff_min(m+1); suff_max[m] = INT_MIN; suff_min[m] = INT_MAX; for(int i = m-1 ; i >= 0 ; i--) { suff_max[i] = max(suff_max[i+1], value[i+1]); suff_min[i] = min(suff_min[i+1], value[i+1]); } vector<int>ans(n); for(int i = 0 ; i < n ; i++) { int p = m; int l = 0, r = m-1; while(l <= r) { int mid = (l+r)/2; if(suff_max[mid] - suff_min[mid] > c[i]) { l = mid+1, p = mid; } else { r = mid-1; } } if(value[p+1] == suff_min[p]) { // smaller side ans[i] = c[i] - (suff_max[p] - value[m]); } else { ans[i] = value[m] - suff_min[p]; } } return ans; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccjBJnfl.o: in function `main':
grader.cpp:(.text.startup+0x30e): undefined reference to `distribute_candies(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status