QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#693418 | #9529. Farm Management | xiaomo | WA | 0ms | 3600kb | C++20 | 632b | 2024-10-31 16:06:56 | 2024-10-31 16:06:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
typedef struct Node{
ll w,l,r;
}node;
bool cmp(node a,node b){
return a.w>b.w;
}
void solve(){
ll n,m;cin>>n>>m;
ll ans=0;
vector<node> a(n);
ll sm=0;
for(ll i=0;i<n;i++){
cin>>a[i].w>>a[i].l>>a[i].r;
sm+=a[i].w;
}
sort(a.begin(),a.end(),cmp);
ll add=0;
ll c=m;
for(ll i=0;i<n;i++){
ans+=a[i].w*a[i].l;
m-=a[i].l;
}
for(ll i=0;i<n;i++){
add=max(add,min(m,c-a[i].l)*a[i].w);
}
cout<<ans+add;
return;
}
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3600kb
input:
5 17 2 3 4 6 1 5 8 2 4 4 3 3 7 5 5
output:
99
result:
wrong answer 1st lines differ - expected: '109', found: '99'