Aggressive Cows SPOJ

Code:

#include <iostream>
#include <algorithm>

using namespace std;

int solve(int A[], int s, int cows, int x) {
    int cplaced = 1;
    int last = A[0];
    for (int i = 1; i < s; i++) {
        if (A[i] - last >= x) {
            if (++cplaced == cows) return 1;
            last = A[i];
        }
    }
    return 0;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n, c;
        cin >> n >> c;
        int Arr[n];
        for (int i = 0; i < n; i++) cin >> Arr[i];
        sort(Arr, Arr + n);
        int l = 0, h = Arr[n-1]-Arr[0];
        while (l < h) {
            int m = (l + h) / 2;
            if (solve(Arr, n, c, m)) l = m + 1;
            else h = m - 1;
        }
        cout << l << "\n";
    }
    return 0;
}

Problem link: SPOJ.com - Problem AGGRCOW

For some reason I get WA. Can someone tell me where I’m going wrong?

Are you sure this line is correct ?