蒟蒻 30分求助 QWQ !
查看原帖
蒟蒻 30分求助 QWQ !
528377
HaoranZing楼主2022/8/2 17:12
#include <bits/stdc++.h>

using namespace std ; 

int n ;

int ans = 0 ;

struct node {

    int mode , w , t ;

} e[100005] ;

queue < node > q ;

int main ( ) {

		cin >> n ;

	for ( int i = 1 ; i <= n ; i++ ) {

        cin >> e[i].mode >> e[i].w >> e[i].t ;

        if ( e[i].mode == 0 ) {

			node u ;

            u.mode = 0 ;

            u.w = e[i].w ;

            u.t = e[i].t ;

            ans += e[i].w ;

            q.push ( u ) ;

        }

        else {

            bool flag = 0 ;

            while ( ! q.empty() ) {

                node u = q.front () ;

                q.pop() ;

                if ( e[i].t - u.t <= 45 && e[i].w <= u.w ){

                    flag = 1 ;

                    break ;

                }

            }

            if ( flag == 0 ) {

                ans += e[i].w ;

            }

        }

    }

    cout << ans ;

	

    return 0 ;

}
2022/8/2 17:12
加载中...