online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <cstring> #include <algorithm> #include <bits/stdc++.h> #define ll long long using namespace std; bool yes(ll int a[],int n,int c,ll int mid){ ll int last = a[0]; int crr = 1; for(int i=1;i<n;i++){ if(abs(a[i]-last)>=mid){ last = a[i]; crr++; if(crr==c){ return true; } } } return false; } int main(){ int n,c; cin >> n>> c; ll int minn = INT_MAX,maxx = INT_MIN; ll int a[n]; for(int i=0;i<n;i++){ cin >> a[i]; minn = min(minn,a[i]); maxx = max(maxx,a[i]); } //cout<<minn<<" "<<maxx<<"\n"; ll int sta = minn,end = maxx-minn,ans = 0; while(sta<=end){ ll int mid = (sta+end)/2; if(yes(a,n,c,mid)){ ans = mid; sta = mid+1; } else{ end = mid-1; } } cout<<ans; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue