Diamond Collector, USACO
#include <fstream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
ifstream cin ("diamond.in") ;
ofstream cout ("diamond.out") ;
int main() {
int n, k, ans=0, maxx=0 ;
cin >> n >> k ;
vector<int> v1(n) ;
for (int i=0; i<n; i++) {
cin >> v1[i] ;
maxx = max(v1[i], maxx) ;
}
for (int i=0; i<maxx-k; i++) {
int temp_ans=0 ;
for (int j=0; j<n; j++) {
if (i < v1[j] && v1[j] < i+k+2) {
temp_ans++ ;
}
}
ans = max(temp_ans, ans) ;
}
cout << ans << endl ;
return 0 ;
}
running this code, I got an error on test case 6. I checked the test case, but it’s too long for me to debug. Can someone find something I did wrong?