algorithmic paradigm is greedy

Active In

Competitive Programming

CP noobs

Machine Learning

Deep Learning

Bitcoin and Blockchain

Commonlounge Meta

Big Data

Product Management

UI/UX Design

Algorithms and Data Structures

Featured Contributions

reply in this discussion

reply in this discussion

Ayan Ali1y

have figured out some ideas working on them if it doesnt works will ask u earlier i thought my code was linear but it wasnt....it was getting tle in 2nd half

Read more… (31 words)

reply in this discussion

reply in this discussion

reply in this discussion

reply in this discussion

Ayan Ali1y

#include<bits/stdc++.h>#define gc getchar_unlockedusing namespace std;void scanint(int &x){register int c = gc();x = 0;int neg = 0;for(;((c<48 || c>57) && c != '-');c = gc());if(c=='-') {neg=1;c=gc();}for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}if(neg) x=-x;}int main(){int n,k,x,z,i,temp,count=0;vector<int> vect;scanint(n);scanint(k);for(i=0;i<n;i++){scanint(x);vect.push_back(x);}x=n-1,z=0;for(i=0;i<n;i++){if(x>i){temp=abs(vect[x]-vect[i]);if(temp>=k)count++;x--;i--;}else{x=n-1;i=z;z++;}}cout<<count ;return 0;}

Read more…

reply in this discussion

Ayan Ali1y

if suppose you have 5 values 1*1, 1*1, 1*1,1*1,4*4 output should be 2. but when u reach 4 value of y becomes 25..bcoz value of y is continuously increasing..while 4*4 can be reduced to 2*2.

Read more… (35 words)

reply in this discussion

reply in this discussion