You are not logged in. Please login at to post your questions!


Why is my code not accepted by codechef ?It is giving a NZEC error everytime I try submitting it.

import java.util.; import java.lang.; import*; class Codechef { public static void main (String[] args) throws IOException { Scanner sc=new Scanner(; int t=sc.nextInt(); if(t>10||t<1)System.exit(0); long p=1,j,n,k,min=0,suml=0,sumr=0; int i; long a[]; long ret[]=new long[t]; for(i=0;i<t;i++) {="" n="sc.nextLong();" if(n<2||n="">(long)Math.pow(10,5))System.exit(0); k=sc.nextLong(); if(k<2||k>(long)Math.pow(10,9))System.exit(0); a=new long[(int)n]; for(j=0;j<n;j++) { a[(int)j]=sc.nextLong(); a[(int)j]=(long)Math.pow(a[(int)j],k); } min=(long)Math.abs(sum(a,1,n)-a[0]); for(j=2;j<n;j++) { suml=sum(a,0,j); sumr=sum(a,j,n); if(min==0)break; if((long)Math.abs(sumr-suml)<min) { p=j; min=(long)Math.abs(sumr-suml); } } ret[i]=p; p=1; } for(i=0;i<t;i++) System.out.println(ret[i]); } static long sum(long a[],long p,long q) { long sum=0; for(long i=p;i<q;i++)sum+=a[(int)i]; return sum; } }

asked 11 Jan, 00:38

ansh_shanker's gravatar image

accept rate: 0%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 11 Jan, 00:38

question was seen: 32 times

last updated: 11 Jan, 00:38