51分 炸了
查看原帖
51分 炸了
289056
北射天狼楼主2022/5/26 21:46

题目通道 我打了一点简单的暴力 51分

好像是因为很坑的题目要求?(不知道)?

#include <bits/stdc++.h>
using namespace std;
long long a[1000100];
long long maxn=-1,minn=-1;
long long large=-1,small=0x3f3f3f3f;
long long l,r;
long long t;
int main(){
	cin>>t;
	while (t--){
		cin>>l>>r;
		large=max(large,r);
		small=min(small,l);//求值
		for (long long i=l;i<=r;i++)    a[i]+=1LL;
	}
	/*for (long long i=small;i<=large;i++){
		cout<<a[i]<<" ";
	}*/
	long long i=small,temp1,temp2;
	while (i<=large){//暴力枚举
		temp1=0;temp2=0;
		while (a[i]>=1&&i<=large)    i++,temp1++;
		maxn=max(temp1,maxn);
		while (a[i]==0&&i<=large)    i++,temp2++;
		minn=max(temp2,minn);
	}
	cout<<maxn-1<<" "<<minn+1<<endl;
	return 0;
}
2022/5/26 21:46
加载中...