ZCO 2015 Discussion

This is my code for variation . It fetched me 100 pts in the grader but i want to know whether its

full efficient or not .( PLEASE COMMENT )

#include

#include

using namespace std;

int main()

{

ios::sync_with_stdio(0);

int n,k;

cin>>n>>k;

int a[n];

for(int i=0;i<n;++i)

cin>>a[i];

int c=0;

sort(a,a+n);

for(int i=n-1;i>=1;i–)
{

for(int j=i-1;j>=0;j–)

{

if(a[i]-a[j]>=k)

{

c=c+j+1;

break;

}

}

}

cout<<c;

return 0;

}

http://pastebin.com/2NYz9hsn

guys this was my code for covering .i got 100 points (till now) dont now future .I can explain my code if theres a problem .
please tell me if any case is coming wrong

2 Likes

I think the cutoff for both morning and afternoon would be 100/200 .

I took the morning session and got 100 in Variation.
I ran out of time for Breakup.
Let’s see whether 100 would be enough to qualify.

Don’t you think that this would give TLE?

I did the same thing but I made a really strong test case and it didn’t pass it.

No, he has got perfect score. His algorithm is O(N) after sorting which is the best you can do I think.

No I am talking about the other link that he has given. Try this test case:
65000 1000
1 1 1 …and 64997 1’s

This would take 64999*65000/2 steps.

Yay! I got an email saying I had qualified! I got 100.

@potatio Can you please confirm if you took part in the morning session or the afternoon one? I had a full score in the morning session, but haven’t received anything yet.

Took part in the morning session. You will definitely receive one then.

Yeah, I got full as well and got an email, so I can confirm that the cutoff is not more than 200 :stuck_out_tongue:

The 40 point subtask for rectangle was just brute force, and it’s arguably easier than the first problem of the morning session.

However the psychological factor is not to be underestimated - if I had done the afternoon session I would certainly not be aiming to get 40, so I might have tried to get 200 and failed to get anything at all. But seen on its own the 40 point subtask was easier than getting 200 in the morning session.