GSRM01A - Editorial

ad-hoc
easy
editorial
gsts2016

#1

PROBLEM LINK:

https://www.codechef.com/problems/GSRM01A

Author: Omkar Prabhu

Tester: Omkar Prabhu

Editorialist: Omkar Prabhu

DIFFICULTY:

EASY

PROBLEM:

You have to find if in-order sum(starting from index 1 to N) at any moment, is greater than or equal to K or not.

EXPLANATION:

Given an array A[N] and K, start your sum from A[1] till A[N].

If sum exceeds or is equal to K, print YES.

If sum after adding all elements or while adding each never exceeds or is equal to K, print NO.

AUTHOR’S AND TESTER’S SOLUTIONS:

Solution: http://ideone.com/hw0agC


#2

#include<stdio.h>
#include<conio.h>
voidmain()
{
int a[n],k,i,sum=0;
printf(“enter elements”);
scanf("%d",&a*);
for(i=1;i<=n;i++)
{sum=sum+a*
}
if(sum>=k)
{printf(“yes”);
}
else
{printf("no);
}
getch();
}