QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#737009 | #9529. Farm Management | tamata_1 | WA | 1ms | 8100kb | C++23 | 1.1kb | 2024-11-12 14:14:46 | 2024-11-12 14:14:51 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct edge{
int w,l,r,num;
};
edge a[100010];
bool cmp(const edge&a,const edge&b){
return a.w<b.w;
}
int w[100010],l[100010],r[100010];
int acc1[100010],acc2[100010];
void solve(){
int n,m;
cin>>n>>m;
int sum=0,cnt=0;
for(int i=1;i<=n;i++){
int li,wi,ri;
cin>>wi>>li>>ri;
cnt+=li;
sum+=li*wi;
a[i].w=wi;
a[i].l=li;
a[i].r=ri;
a[i].num=ri-li;
}
int maxx=0;
memset(acc1,0,sizeof(acc1));
memset(acc2,0,sizeof(acc2));
cnt=m-cnt;
sort(a+1,a+1+n,cmp);
for(int i=n;i>=1;i--){
acc1[i]+=acc1[i+1]+a[i].num;
acc2[i]+=acc2[i+1]+a[i].num*a[i].w;
w[i]=a[i].w;
r[i]=a[i].r;
l[i]=a[i].l;
}
for(int i=1;i<=n;i++){
cout<<acc1[i]<<" ";
}
cout<<endl;
cout<<cnt<<endl;
for(int i=1;i<=n-1;i++){
int x=cnt+l[i];
int pos=lower_bound(acc1+1,acc1+1+n,x,greater<int>())-acc1;
cout<<x<<" "<<pos<<endl;
if(pos<=i){
pos=i+1;
}
maxx=max(maxx,acc2[pos]+(x-acc1[pos]*w[pos-1]));
}
maxx=max(maxx,cnt*w[n]);
cout<<maxx+sum<<endl;
}
signed main(){
int T=1;
while(T--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 8100kb
input:
5 17 2 3 4 6 1 5 8 2 4 4 3 3 7 5 5
output:
7 6 6 2 2 3 6 2 6 2 4 4 8 1 109
result:
wrong answer 1st lines differ - expected: '109', found: '7 6 6 2 2 '