NOIP 2011 Day1 T2 选择客栈

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
struct data{
    int sd,xf;
};
    data co[200005];
int n,k,p,ans,cnt,minn=210000,s;
int sum[55][200005],st[200005];
int main()
{
    freopen ("hotel.in","r",stdin);
    //freopen ("hotel.out","w",stdout);
    scanf ("%d%d%d",&n,&k,&p);
    for (int i=1;i<=n;i++)
    {
        scanf ("%d%d",&co[i].sd,&co[i].xf);
        for (int j=0;j=1;i--)//here
    {
        if (co[i].xf<=p)  minn=min(minn,i);
        st[i]=minn;
    }
    for (int i=1;i<=n-1;i++)
    {
        if (st[i]>200000)  continue;
        if (st[i]==i)  ans+=sum[co[i].sd][n]-sum[co[i].sd][i];
        else ans+=sum[co[i].sd][n]-sum[co[i].sd][st[i]-1];
    }
    printf ("%d",ans);
    return 0;
}

你可能感兴趣的:(NOIP 2011 Day1 T2 选择客栈)