Cod sursa(job #2024334)

Utilizator Cristi_ChiraChira Cristian Cristi_Chira Data 20 septembrie 2017 14:00:29
Problema Schi Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.86 kb
#include <iostream>
#include <fstream>
#include <deque>
#define lsb(x) (x&(-x))
#define dm 30005
using namespace std;
ifstream fin("schi.in");
ofstream fout("schi.out");
int aib[dm], n, ax[dm], schiori[dm];
void add(int x, int q)
{
    for(int i = x; i <= n; i+=lsb(i))
        aib[i] += q;
}
int query( int x )
{
    int result = 0;
    for( int i = n; i > 0; i -= lsb(i))
        result += aib[i];

    return result;
}
void cb ( int x )
{
    int m, dr = n, st = 1, chestie = n + 1 ;
    while( dr>=st )
    {
        m = ( dr + st ) / 2;
        if( query(m) == a[] && chestie > m)
        {
            chestie = m;
            dr = m - 1;
        }
        else if ( query(m) >= )
    }
}
int main()
{
    int aux;
    fin >> n;
    for( int i = 1; i <= n; i++ )
    {
        fin >> aux;
        add(i, aux);
    }
    return 0;
}