QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#683288 | #9529. Farm Management | estrellad# | WA | 1ms | 5696kb | C++14 | 1.1kb | 2024-10-27 19:53:20 | 2024-10-27 19:53:21 |
Judging History
answer
// dzx
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
const int N=2e5+10;
const int M=N-10,INF=1e18+10,P=998244353;
typedef pair<int,int> PII;
#define fi first
#define se second
int n,m;
struct node{
int v,l,r;
}q[N];
int cmp(node a,node b){
if(a.v!=b.v)return a.v<b.v;
return a.r>b.r;
}
int s[N],rs[N];
void solve(){
cin>>n>>m;
for(int i=1;i<=n;i++){
int v,l,r;
cin>>v>>l>>r;
q[i]={v,l,r};
}
sort(q+1,q+1+n,cmp);
int res=0,ss=0,ans=0;
for(int i=1;i<=n;i++){
auto [v,l,r]=q[n+1-i];
res+=l*v;
ss+=l;
s[i]=s[i-1]+(r-l);
rs[i]=rs[i-1]+(r-l)*v;
}
for(int i=1;i<=n;i++){
auto [v,l,r]=q[i];
int ti=m-ss+l;
int id=lower_bound(s+1,s+1+n,ti)-s;
int trid=n-id+1;
if(trid<i){
int daoi=n-i+1;
ans=max(ans,res-l*v+rs[daoi-1]+(ti-s[daoi-1])*q[i].v);
}else{
ans=max(ans,res-l*v+rs[id-1]+(ti-s[id-1])*q[id].v);
}
}
cout<<ans<<endl;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int _T=1;
// cin>>_T;
while(_T--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5696kb
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: 5648kb
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:
33694444
result:
wrong answer 1st lines differ - expected: '35204500', found: '33694444'