QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#687102#9529. Farm ManagementMENDAX#WA 1ms5764kbC++201.3kb2024-10-29 17:15:442024-10-29 17:15:45

Judging History

你现在查看的是最新测评结果

  • [2024-10-29 17:15:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5764kb
  • [2024-10-29 17:15:44]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n,m;
#define pii pair<ll,ll>
#define mp make_pair
const int N = 1e5 + 10;
pair<ll,pii> p[N];
ll ans,res,pre[N],finans,val[N];

void solve(int x) {
	ll nowres = res + p[x].second.first;
	ll now = ans - p[x].second.first * p[x].first;
	int pos = lower_bound(pre+1,pre+x,res) - (pre);
	//cout <<"debug:x:" <<x << "nowres:" << nowres << "now:"<<now<< "pos:"<<pos <<"\n";
	now += val[pos];nowres -= pre[pos];
	if (nowres) now += p[pos].first * nowres;
	//cout <<"debug:now:" <<now<<"\n";
	finans = max(finans,now);
}

signed main() {
	ios::sync_with_stdio(false);
	cin >>n >>m;
	for (int i = 1;i <= n;++i) {
		ll x,l,r;cin >> x >> l >> r;
		p[i] = mp(x,mp(l,r));
	} 
	sort(p+1,p+1+n);
	reverse(p+1,p+1+n);
	//´Ó´óµ½Ð¡
	res = m;
	for (int i = 1;i <= n;++i) {
		ans += (p[i].second.first) * p[i].first;
		res -= p[i].second.first;
		pre[i] = pre[i-1] + (p[i].second.second - p[i].second.first);
		val[i] = val[i-1] + (p[i].second.second - p[i].second.first) * p[i].first;
	} 
	//printf("pre:");for (int i = 1;i <= n;++i) cout <<pre[i] << " "; cout << "\n"; 
	//printf("val:");for (int i = 1;i <= n;++i) cout <<val[i] << " "; cout << "\n"; 
	finans = ans;
	for (int i = 1;i <= n;++i) {
		solve(i);
	}
	cout << finans;
}

/*
3 20
1 10 11
2 9 10
3 1 20
*/

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3592kb

input:

5 17
2 3 4
6 1 5
8 2 4
4 3 3
7 5 5

output:

109

result:

ok single line: '109'

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 5764kb

input:

12 62
503792 9 10
607358 1 3
600501 10 10
33249 4 4
774438 6 6
197692 3 6
495807 8 8
790225 5 9
77272 3 8
494819 4 9
894779 3 9
306279 5 6

output:

35277263

result:

wrong answer 1st lines differ - expected: '35204500', found: '35277263'