here is only basic implementation of problems for beginners. If you have any problem with any solution or any basic concept of programming or you want more efficient solution you can mail me.
my suggestion is not to copy and paste codes from here try to understand the logic and think why you were not able to solve it.

Thursday, 23 October 2014

Distracted judges

problem statement is here


#include<stdio.h>
int main(){
long a,b,c,d,i,j,t,n;
scanf("%ld",&t);
long ar[100005],br[100005],cr[100005]={0};
for(i=0;i<t;i++){
scanf("%ld",&ar[i]);
}
j=0;
br[j]=t;
j++;
a=1;
for(i=t-2;i>=0;i--){
if(ar[i]==a){
br[j++]=i;
cr[i]=1;
}else if(cr[i+ar[i]+1]==1){
br[j++]=i;
cr[i]++;
}
a++;
}
for(i=j-1;i>=0;i--){
if(br[i]!=0)
printf("%ld\n",br[i]);
}
return 0;
}

No comments:

Post a Comment