QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#785473#9529. Farm ManagementSZH#WA 1ms5604kbC++141.2kb2024-11-26 18:02:202024-11-26 18:02:40

Judging History

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

  • [2024-11-26 18:02:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5604kb
  • [2024-11-26 18:02:20]
  • 提交

answer

#include<bits/stdc++.h>
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back

using namespace std;

inline ll read()
{
	ll f=1,sum=0;char c=getchar();
	while (!isdigit(c)) {if (c=='-') f=-1;c=getchar();}
	while (isdigit(c)) {sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}

const int maxn=111111;
ll A[maxn],L[maxn],R[maxn],id[maxn];
ll sumt[maxn],sumv[maxn];

bool cmp(int x,int y)
{
	return A[x]<A[y];
}

int main()
{
	ll N=read(),M=read();
	for(int i=1;i<=N;++i) A[i]=read(),L[i]=read(),R[i]=read(),id[i]=i;
	sort(id+1,id+1+N,cmp);
	for(int ii=N;ii>=1;--ii)
	{
		int i=id[ii];
		sumt[i]=sumt[i+1]+R[i]-L[i];
		sumv[i]=sumv[i+1]+(ll)(R[i]-L[i])*A[i];
	}
	ll ANS=0,tott=0,totv=0;
	for(int i=1;i<=N;++i) tott+=L[i],totv+=L[i]*A[i];
	for(int ii=1;ii<=N;++ii)
	{
		int i=id[ii];
		int l=i+1,r=N,ans=N+1;
		while(l<=r)
		{
			int mid=(l+r)/2;
			if(sumt[mid]+tott-L[i]<=M) ans=mid,r=mid-1;
			else l=mid+1;
		}
		ANS=max(ANS,totv-(ll)L[i]*A[i]+sumv[ans]+A[ans-1]*(M-(sumt[ans]+tott-L[i])));
	}
	cout<<ANS;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5552kb

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: 5604kb

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:

34089197

result:

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