2 条题解

  • 0
    #include<bits/stdc++.h>
    #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    using namespace std;
    const int N=1e5+10;
    const int INF=0x3f3f3f3f;
    int n,cst,l,st=1;
    struct take_way{
    	int p,t;
    	short wy;
    }a[N];
    struct tickit{
    	int tm,pc;
    	bool hd=0;
    }c[N];
    int main()
    {
    	IOS;
    	cin>>n;
    	for(int i=1;i<=n;++i)
    	{
    		cin>>a[i].wy>>a[i].p>>a[i].t;
    		if(a[i].wy==0)
    		{
    			cst+=a[i].p;
    			++l;
    			c[l].tm=a[i].t+45;
    			c[l].pc=a[i].p;
    			//cout<<"坐地铁:"<<a[i].p<<endl;
    		}
    		else
    		{
    			bool f1=0;
    			for(int j=st;j<=l;++j)
    			{
    				if(a[i].p<=c[j].pc && a[i].t<=c[j].tm && c[j].hd==0)
    				{
    					f1=1;
    					c[j].hd=1;
    					//cout<<"不花费"<<endl; 
    					break;
    				}
    				else if(a[i].t>c[j].tm)
    				{
    					st=j;
    				}
    			}
    			if(!f1)
    			{
    				cst+=a[i].p;
    				//cout<<"坐公交:"<<a[i].p<<endl; 
    			}
    		}
    	}
    	cout<<cst;
        return 0;
    }
    
    • 0
      @ 2023-12-24 9:52:09

      1

      • 1

      信息

      ID
      786
      时间
      1000ms
      内存
      256MiB
      难度
      7
      标签
      递交数
      302
      已通过
      78
      上传者