ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1028. Stars

I don't understand Im getting TLE on test 3
Posted by alkaid 30 Jun 2011 02:15
I'm using BIT

this is my c++ solution

#include <stdio.h>

#define mxn 15005
#define mxm 32005

int l[mxn];
int b[mxm];
int n;

int get(int x)
{
    int s = 0;
    while(x > 0)
    {
            s += b[x];
            x -= (x & -x);
    }
    return s;
}

void add(int x)
{
    while(x < mxm)
    {
        b[x]++;
        x += (x & -x);
    }
}

int main()
{
        scanf("%d",&n);
        for(int i = 0; i < n; i++)
        {
                int a,b;
                a++;
                scanf("%d%d",&a,&b);
                l[get(a)]++;
                add(a);
        }

        for(int i = 0; i < n; i++)
            printf("%d\n",l[i]);
}
Re: I don't understand Im getting TLE on test 3
Posted by alkaid 30 Jun 2011 02:17
sorry, hehe, but position to my "a++"