PUBG Lover Programmer: The Beginning

Sroud loves to play PUBG and does programming contest. He always thinks about converting gameplay to…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

#include<stdio.h>
int main()
{
    int n,x,arr[120],sum=0,res;
    scanf("%d %d",&n,&x);
    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
        sum+=arr[i];
        res=sum-x;
    }

    printf("%d\n",res);
}

why i got runtime error

1 Like

@Dibbendu.040619 The input specification of this problem was not formatted correctly (e.g. 10^5 was being shown as 105). The statement has been updated.

Please try solving the problem again with the correctly formatted problem statement.

Sorry for the inconvenience.

#include<stdio.h>
int main()
{

    long int n,x,sum=0,res,arr[100000];
    scanf("%d %d",&n,&x);

    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
        sum+=arr[i];
        res=sum-x;
    }

    printf("%d\n",res);
}

why i got error on test case 2