题目
题解思路
一开始枚举温度 排序二分去了,仔细思考发现并不能保证另一边的情况。
所以不能二分。
N只有20万个。我们可以直接差分,即对每个温度区间的情况都差分。
然后就能直接枚举出答案。
这里能直接利用map来离散化。
超级暴力。
AC代码
#include <bits/stdc++.h>
//#include <unordered_map>
//priority_queue
#define PII pair<int,int>
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 200100;
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
long long n , x , y ,z ;
cin >> n >> x >> y >> z ;
map <long long , long long > mp ;
for (int i = 1 ; i <= n ; i++ )
{
int t1 , t2 ;
cin >> t1 >> t2 ;
mp[0] += x ;
mp[t1] -= x ;
mp[t1] += y ;
mp[t2+1] -= y ;
mp[t2+1] += z ;
}
long long ans = 0 ;
long long last = -1 ;
for ( auto & i : mp )
{
if (last != -1 )
i.second += mp[last] ;
ans = max(ans,i.second) ;
last = i.first ;
}
cout << ans << "\n" ;
return 0 ;
}