[文本]https://xazxoi.cn/record/6947cd185279694783324125

#include <iostream>
#include <vector>

using namespace std;

long long n , total = 0; 
struct human
{
	int id;
	long long price;
	long long time;
	int use;
	
};

int main()
{
    cin >> n;
    vector<human> humans(n);
    for (int i = 0; i < n ; i++)
    {
    	cin >> humans[i].id >> humans[i].price >> humans[i].time;
    	humans[i].use = 0;
	}
	for (int i = 0 ; i < n ; i++)
	{
		if (humans[i].id == 0)
		{
			total += humans[i].price;
		}
		else
		{
			int used = -1;
			long long et = 1e18;
			for (int j = 0 ; j < i ; j++)
			{
				if (humans[j].id != 0 || humans[j].use == 1)
				{
					continue;
				}
				if (humans[i].time - humans[j].time > 45)
				{
					continue;
				}
				if (humans[j].price >= humans[i].price && humans[j].time < et)
				{
					et = humans[j].time;
					used = j;
				}
				
			}
			if (used != -1)
			{
				humans[used].use = 1;
			}
			else
			{
				total += humans[i].price;
			}
		}
	}
	cout << total << endl;
    return 0;
}

0 comments

No comments so far...

Information

ID
666
Time
1000ms
Memory
256MiB
Difficulty
5
Tags
# Submissions
38
Accepted
15
Uploaded By