Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8891037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:38:14+00:00 2026-06-14T22:38:14+00:00

I have written the solution code of Jolly Jump problem (ACM 10038 uva). My

  • 0

I have written the solution code of Jolly Jump problem (ACM 10038 uva).
My Code is as follows:

#include<stdio.h>
#include<stdlib.h>

int main(){
  int count=0;
  int Number[3000]={0};
  int Absolute[3000]={0};
  bool flag=true;
  while(scanf("%d",&count)){
   for(int i=0;i<count;++i){
     scanf("%d",&Number[i]);
     Absolute[i]=0;
   }
   for(int j=0;j<count-1;++j){
     int diff=Number[j]-Number[j+1];
     if(diff<0)diff*=-1;
     Absolute[diff]=1;
   }
   flag=true;
   for(int x=1;x<count;++x){
     if(Absolute[x]!=1){
       flag=false;
       break;
     }
   }
   if(flag)printf("Jolly\n");
   else printf("Not Jolly\n");
 }
 return 0;
}

But the conmmited result is Time limit exceeded. Why? How do I revise my code to lower the run time?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:38:15+00:00Added an answer on June 14, 2026 at 10:38 pm

    Your program is probably exceeding the time limit because it never finishes. If/when scanf() returns EOF, the following will never stop looping:

    while(scanf("%d",&count)){
        // whatever...
    }
    

    In these online programming problems, it’s usually a good idea to at least run your proposed solution against the example data they provide in the question and see if you get the expected output. If your program doesn’t produce the expected output, then you know you have a problem to fix (and you have something concrete to debug).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written this code in JavaScript and works perfectly fine when I include
I have written a source code like: int main(int argc, char *argv[]) { QFile
Does anyone have a solution for a basic, compact Finite state machine/automata written in
I have written this code inside a servlet to delete certain records from three
I have written below code to check for blank value in my textbox but
I have written some code that works pretty well, but I have a strange
I have strange problem for which I can't think of a solution. I have
I have written an algorithm which iteratively solves the problem. The first iteration consists
I have written a code generator using CodeDom and it generates a number of
I have written some code which compiles fine under linux but on Solaris I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.