GSRM01A - Editorial

PROBLEM LINK:

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: hw0agC - Online C++ Compiler & Debugging Tool - Ideone.com

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