文章

37

粉丝

1

获赞

353

访问

24.6k

头像
教室分配问题2 题解:
P8714 复旦大学2025年机试题
发布于 2026年3月
阅读数 630

#include<bits/stdc++.h>
using namespace std;
const int N = 1e9;

int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int n; cin>>n;
	
	map<int,pair<int,int>> courses;

	
	for(int i = 0 ; i < n; i ++){
		int s,e,c; cin>>s>>e>>c;
		if(c<=20){
			courses[s].first++;
			courses[e].first--;
		}
		else{
			courses[s].second++;
			courses[e].second--;
		}
	}
	
	int ans1 = 0;
	int ans2 = 0;
	int tmp1=0,tmp2=0;
	for(auto it : courses){
		tmp1 += it.second.first;
		tmp2 += it.second.second;
		ans1 = max(ans1,tmp1+tmp2);
		ans2 = max(ans2,tmp2);
	}
	cout<<ans1<<' '<<ans2<<endl;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发