记录编号 172861 评测结果 AAAAAAAAAAAAAAAAAAAA
题目名称 [USACO NOV]金发姑娘和N头牛 最终得分 100
用户昵称 Gravatar啊吧啦吧啦吧 是否通过 通过
代码语言 C++ 运行时间 0.065 s
提交时间 2015-07-27 14:06:57 内存使用 3.36 MiB
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <climits>
#include <fstream>
#include <algorithm>

using namespace std;

inline int getint();
const int MAXN = 200001;
int t[2 * MAXN], n, x, y, z, a[MAXN], b[MAXN], ans = INT_MIN;

main()
{
	freopen("milktemp.in", "r", stdin);
	ofstream fout("milktemp.out");
	n = getint();
	x = getint();
	y = getint();
	z = getint();
	for (int i = 1; i <= n; ++i){
		a[i] = getint();
		b[i] = getint();
		
		t[i * 2 - 1] = a[i];
		t[i * 2] = b[i];
	}	
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	sort(t + 1, t + 2 * n + 1);
	int l = 0, r = 0;
	for (int i = 1; i <= 2 * n; ++i){
		int nans;
		while(l < n && t[i] >= a[l + 1])
			l ++;
		while(r < n && t[i] > b[r + 1])
			r ++;
		nans = (n - l) * x + (l - r) * y + r * z;
		ans = max(nans, ans);
	}
	
	fout << ans;
	fclose(stdin);
	fout.close();
//	getchar();	getchar();
}

inline int getint(){
	int x = 0;
	char c;
	while (! isdigit(c = getchar()));
	while (isdigit(c)){
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x;
}