Submission #428562

#TimeUsernameProblemLanguageResultExecution timeMemory
428562Amylopectin휴가 (IOI14_holiday)C++14
24 / 100
5044 ms2844 KiB
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include "holiday.h"
//#include "grader.cpp"
using namespace std;
const long long mxn = 1e5 + 10;
struct we
{
    long long vaa,no;
    bool operator () (const struct we &l,const struct we &r)
    {
        return l.vaa > r.vaa;
    }
};
priority_queue <struct we, vector<struct we >, struct we> qu;
long long fima(long long l,long long r)
{
    if(l > r)
        return l;
    return r;
}
long long int findMaxAttraction(int n, int stn, int d, int att[])
{
    long long i,j,hva,hsi,bsi,ma = 0,of;
    for(i=stn; i>=0; i--)
    {
        while(!qu.empty())
        {
            qu.pop();
        }
        hva = 0;
        of = 0;
        for(j=stn; j>=i; j--)
        {
            qu.push({att[j],j});
            hva += att[j];
        }
        hsi = stn - i + 1;
        bsi = d-(stn-i);
        while(hsi > bsi)
        {
            if(qu.top().no == i)
            {
                of = 1;
                break;
            }
            hva -= qu.top().vaa;
            qu.pop();
            hsi --;
        }
        if(of == 1)
            continue;
        ma = fima(hva,ma);
        for(j=stn+1; j<n; j++)
        {
            qu.push({att[j],j});
            hva += att[j];
            hsi ++;
            bsi = d - ((stn-i)*2 + j-stn);
            if(bsi <= 0)
            {
                break;
            }
            while(hsi > bsi)
            {
//                if(qu.top().no == i)
//                {
//                    of = 1;
//                    break;
//                }
                hva -= qu.top().vaa;
                qu.pop();
                hsi --;
            }
            if(of == 1)
                break;
            ma = fima(ma,hva);
        }
    }
    for(i=stn; i<n; i++)
    {
        while(!qu.empty())
        {
            qu.pop();
        }
        hva = 0;
        of = 0;
        for(j=stn; j<=i; j++)
        {
            qu.push({att[j],j});
            hva += att[j];
        }
        hsi = i - stn + 1;
        bsi = d-(i-stn);
        while(hsi > bsi)
        {
            if(qu.top().no == i)
            {
                of = 1;
                break;
            }
            hva -= qu.top().vaa;
            qu.pop();
            hsi --;
        }
        if(of == 1)
            continue;
        ma = fima(hva,ma);
        for(j=stn-1; j>=0; j--)
        {
            qu.push({att[j],j});
            hva += att[j];
            hsi ++;
            bsi = d - ((i-stn)*2 + stn-j);
            if(bsi <= 0)
            {
                break;
            }
            while(hsi > bsi)
            {
//                if(qu.top().no == i)
//                {
//                    of = 1;
//                    break;
//                }
                hva -= qu.top().vaa;
                qu.pop();
                hsi --;
            }
            if(of == 1)
                break;
            ma = fima(ma,hva);
        }
    }
    return ma;
}
//int main()
//{
//
//    return 0;
//}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...