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

×

i don't understand the subtask

in Pairwise AND sum problem from school catagory there are sub tasks like Subtask 1 (13 points): N <= 1000, Ai <= 1.

Subtask 2 (39 points): N <= 1000, Ai <= 109.

Subtask 3 (21 points): N <= 105, Ai <= 1.

Subtask 4 (27 points): N <= 105, Ai <= 106.

my code is

include <stdio.h>

int main() { long long int n,i,m,x,j; scanf("%lld", &n); long long int ara[n+1];

for(i = 0;i<n;i++)
    scanf("%lld", &ara[i]);

m = 0;
for(i=0;i<n;i++) {
    for(j=0;j<n;j++) {
        if(ara[i] < ara[j])
        m = m + (ara[i]&ara[j]);
    }
}

printf("%lld\n",m);

return 0;

}

it shows i've only done sub task 2 .. others are not done ... i don't understand why.can anyone plz tell me about this.i am new.

asked 23 Jul '14, 17:17

monmoy1357's gravatar image

2★monmoy1357
111
accept rate: 0%


Here your logic is O(n^2) and for n<=10^5 it is definately going to give time limit exceeded. so your 3 and 4 subtasks are TLE'd. So try to optimize your solution. http://www.codechef.com/viewsolution/4369768 here you can see summary of your submission.

link

answered 23 Jul '14, 18:06

aniket20's gravatar image

6★aniket20
2962712
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×690
×26
×13

question asked: 23 Jul '14, 17:17

question was seen: 5,884 times

last updated: 23 Jul '14, 18:06