其他分享
首页 > 其他分享> > 洛谷 P1607 [USACO09FEB]Fair Shuttle G(贪心+信心)

洛谷 P1607 [USACO09FEB]Fair Shuttle G(贪心+信心)

作者:互联网

 

 

const int N=1e5+5;
 
    int n,m;
    int i,j,k;
    struct Node
    {
        int l,r;
        int c;
        void read(){ sddd(l,r,c); }
        bool operator<(Node o){
            if(r==o.r) return l<o.l; //
            return r<o.r;
        }
    } a[N];
    vector<int> seat(100+5);

int main()
{
    //IOS;
    while(~sddd(n,m,k)){
        forn(i,1,n) a[i].read();
        sort(a+1,a+1+n);
        int ans=0;
        for(int i=1;i<=n;i++){
            for(int j=0;j<k;j++){
                if(a[i].c && a[i].l>=seat[j]){
                    ans++;
                    seat[j]=a[i].r;
                    a[i].c--;
                }
            }
            sort(seat.begin(),seat.begin()+k,greater<int>());
        }
        pd(ans);
    }
    //PAUSE;
}

 

标签:sort,begin,洛谷,Fair,int,seat,read,ans,USACO09FEB
来源: https://blog.csdn.net/C_Dreamy/article/details/115355549