QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#783974 | #9529. Farm Management | Xuntongda | WA | 0ms | 3572kb | C++14 | 1.1kb | 2024-11-26 12:29:50 | 2024-11-26 12:29:51 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,t;
long long ans,m,maxx;
struct s{
long long w,l,r,v;
}a[100010];
bool cmp(s a,s b){
if(a.w>b.w)return 1;
else{return 0;
}
}
int main(){
ios::sync_with_stdio(0);
//freopen("farm02.in","r",stdin);
//freopen("farm02.out","w",stdout);
cin>>t;
while(t--){
ans=0,maxx=0;;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i].w>>a[i].l>>a[i].r;
a[i].v=a[i].r-a[i].l;
m-=a[i].l;
ans+=a[i].w*a[i].l;
}
sort(a+1,a+1+n,cmp);
long long h=m+a[1].l,cnt=ans-(a[1].w*a[1].l);
maxx=max(maxx,cnt+(h*a[1].w));
for(int i=n;i>=1;i--){
long long h=m+a[i].l,cnt=ans-(a[i].w*a[i].l);
//cout<<h<<" "<<cnt<<endl;
for(int j=1;j<=n;j++){
if(j==i)continue;
if(a[j].v>h){
cnt+=h*a[j].w;
//cout<<cnt<<endl;
h=0;
break;
}
if(a[j].v<=h){
cnt+=a[j].v*a[j].w;
//cout<<cnt<<endl;
h-=a[j].v;
}
}
maxx=max(maxx,cnt);
//cout<<endl;
//cout<<maxx<<" "<<h<<" "<<cnt<<endl;
}
cout<<maxx<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3572kb
input:
5 17 2 3 4 6 1 5 8 2 4 4 3 3 7 5 5
output:
0 0 0 0 0
result:
wrong answer 1st lines differ - expected: '109', found: '0'