CF1601D Difficult Mountain
一道神必贪心
首先我们分类考虑贪心的几种情况
对于两个人\(i\)与\(j\),并且两人都满足s>p
\(1.s[i]<a[i]\)
\(\space \space 1)\) \(a[i]<s[j]<a[j]\) 显然\(i\)在\(j\)前更优
\(\space \space 2)\) \(a[i]<a[j]<s[j]\) 显然没什么用
\(\space \space 3)\) \(a[j]<a[i]<s[j]\) 显然没什么用
\(\space \space 4)\) \(s[j]<a[i]<a[j]\) 显然\(i\)在\(j\)前更优
\(\space \space 5)\) \(s[j]<a[j]<a[i]\) 显然\(j\)在\(i\)前更优
\(\space \space 6)\) \(a[j]<s[j]<a[i]\) 显然\(j\)在\(i\)前更优
\(2.a[i]<s[i]\)
\(\space \space 1)\) \(s[i]<s[j]<a[j]\) 显然\(j\)在\(i\)前更优
\(\space \space 2)\) \(s[i]<a[j]<s[j]\) 显然\(j\)在\(i\)前更优
\(\space \space 3)\) \(a[j]<s[i]<s[j]\) 显然没什么用
\(\space \space 4)\) \(s[j]<s[i]<a[j]\) 显然\(j\)在\(i\)前更优
\(\space \space 5)\) \(s[j]<a[j]<s[i]\) 显然\(i\)在\(j\)前更优
\(\space \space 6)\) \(a[j]<s[j]<s[i]\) 显然没什么用
把上面综合一下就是这样一个排序:
//mx表示max(s,a)
bool operator < (const node &b) const{
if(mx==b.mx) return s<b.s;
return mx<b.mx;
}
神必贪心,接下来直接判断能否累加上去就行了
标签:const,space,神必,CF1601D,mx,fn,贪心 From: https://www.cnblogs.com/Diamondan/p/17549966.html