17 Aug, 17:39
17 Aug, 07:23
20 Sep, 07:09
02 Jun, 13:14
02 Jun, 13:12
23 May, 08:27
15 Nov, 09:19
08 Nov, 15:06
03 Nov, 14:39
30 Oct, 06:02
23 Oct, 15:41
16 Oct, 10:28
09 Oct, 05:13
03 Oct, 05:29
void precompute(int prefixSum[])
prefixSum[0]=arr[0]
for i=1 to n-1 prefixSum[i]=prefixSum[i-1]+arr[i]
int rangesum(int l,int r,int prefixSum[])
if(l=0)
return prefixSum[r]
else
return prefixSum[r]-prefixSum[l-1]
void update(int i,int x,int prefixSum [],int arr[])
int diff = x-arr[i]
for j=i to n-1
prefixSum[j]=prefixSum[j]+diff
arr[i] = arr[i] + diff
29 Sep, 09:11
int fun(char *x){
char *ptr=x;
while(*ptr!=0)ptr++;
return (ptr-x);
}
int main(){
char str[30]="This is PDS test";
printf("%d",fun(str));
}
int main(){
int array[4]={20,18,16,14};
int *ptr=array;
printf("%d,%d",*ptr+2,*(ptr+2));
}
int *A,*B,C[10];
int main(){
int arr[3]={1,2};
int i;
for(i=0;i<3;i++){
printf("%d ");
}
}
22 Sep, 10:45
int Damage(int n, int a[],int p)Code:
int s = (n-(p+1)) + ceil(p/2)
int d = 0
if(p%2 != 0)
d = d + a[p]
int last = s
int step = 2
while( last != 1)
if((last-1)%step==0)
if(last<=(n-(p+1))
d = d + a[last+p]
else
d = d + a[2*(k-n+p)+1]
else
last = ((last-1)-(last-1)%step)+1
step = step*2
return d
int n,f
n,f=input
n=n-1
int a[n+1]
a[0] = 0;
for i = 1 to n
a[i]=input
int result[n]
initialize result with -1
for i=0 to n
if(a[i]<=f)
result[i]=damage(n,a,i)
int count=0
for i=0 to n
if(result[i]!=-1)
count=count+1
if(count==0)
print "impossible"
else
int index=n+1
int min_damage=INT_MAX
for i = n to 0
if(result[i] != -1 && result[i]<=min_damage)
index=i
min_damage=result[i]
print "possible\n"
print index+1
print min_damage+f
22 Sep, 10:45
20 Sep, 17:30
int pallin_dist(char ch[],int start,int end):
if(end==-1): //i.e end of string
return 0
ans=pallin_dist(ch,start+1,end-1)
if (ch[start]==ch[end]):
return ans
else:
return ans+1
15 Sep, 14:41