QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#688399#9529. Farm ManagementyhdddWA 1ms8052kbC++201.5kb2024-10-30 08:20:272024-10-30 08:20:28

Judging History

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

  • [2024-10-30 08:20:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:8052kb
  • [2024-10-30 08:20:27]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define mod 998244353ll
#define pii pair<int,int>
#define fi first
#define se second
#define mems(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define db double
using namespace std;
const int maxn=200010;
const int inf=1e18;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch-48);ch=getchar();}
	return x*f;
}
bool Mbe;

int n,m,ans;
struct nd{
	int a,l,r;
}a[maxn];
int t[maxn],f[maxn],g[maxn];
void work(){
	n=read();m=read();int mx=0;
	for(int i=1;i<=n;i++)a[i]={read(),read(),read()};
	sort(a+1,a+n+1,[&](nd u,nd v){return u.a>v.a;});
	int sum=0,cur=0;
	for(int i=1;i<=n;i++)t[i]=a[i].l,sum+=a[i].a*a[i].l,cur+=a[i].l;
	for(int i=1;i<=n;i++){
		int d=min(m-cur,a[i].r-a[i].l);
		t[i]+=d,sum+=a[i].a*d,cur+=d;
	}
	ans=sum+a[1].a*(m-cur);
	for(int i=1;i<=n;i++){
		f[i]=f[i-1]+(a[i].r-t[i]);
		g[i]=g[i-1]+(a[i].r-t[i])*a[i].a;
	}
	for(int i=1;i<=n;i++){
		int d=m-cur+t[i];
		int p=upper_bound(f+1,f+n+1,d)-f-1;
		// cout<<ans<<" "<<i<<" "<<p<<" "<<sum-t[i]*a[i].a+g[p]+(p<i?(d-f[p])*a[p+1].a:(d-f[p])*a[i].a)<<"\n";
		ans=max(ans,sum-t[i]*a[i].a+g[p]+(p<i?(d-f[p])*a[p+1].a:(d-f[p])*a[i].a));
	}
	printf("%lld\n",ans);
}

// \
444

bool Med;
int T;
signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	
//	ios::sync_with_stdio(0);
//	cin.tie(0);cout.tie(0);
	
//	cerr<<(&Mbe-&Med)/1048576.0<<" MB\n";
	
	T=1;
	while(T--)work();
}

詳細信息

Test #1:

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

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: 0
Accepted
time: 1ms
memory: 7860kb

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:

35204500

result:

ok single line: '35204500'

Test #3:

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

input:

15 32
835418 2 3
178262 1 3
527643 2 2
519710 1 1
774544 3 3
82312 1 1
808199 1 1
809396 1 3
255882 1 3
80467 1 3
874973 1 3
813965 1 2
198275 1 2
152356 1 3
802055 1 1

output:

17015002

result:

wrong answer 1st lines differ - expected: '22000255', found: '17015002'