can someone help me with mys solution for the following problem

Problem AGGRCOW

Here is my code :

#include <bits/stdc++.h>

#include <cmath>

#include <algorithm>

using namespace std;

#define ll long long

int func(vector<ll int> v,int n,int c,ll int x){

ll int cowsPlaced=1,lastPos=v[0];

for (int i = 1; i < n; ++i)