文章

37

粉丝

1

获赞

316

访问

9.5k

头像
教室分配问题 题解:
P5372 复旦大学2025年机试题
发布于2026年3月4日 14:30
阅读数 433

差分

#include<bits/stdc++.h>
using namespace std;

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

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发