QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#683342 | #9529. Farm Management | wjynb666 | WA | 0ms | 3620kb | C++11 | 879b | 2024-10-27 20:21:27 | 2024-10-27 20:21:31 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define read_fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using ll=long long;
const int N=1e5+10;
struct node{
ll v,l,r;
}a[N];
bool cmp(node a,node b){
if(a.v!=b.v) return a.v>b.v;
if(a.l!=b.l) return a.l<b.l;
return a.r<b.r;
}
int main()
{
read_fast
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i].v>>a[i].l>>a[i].r;
}
sort(a+1,a+1+n,cmp);
ll ans=0;
for(int i=1;i<n;i++){
ans+=a[i].v*a[i].l;
m-=a[i].l;
}
for(int i=1;i<=n;i++){
if(m>a[i].r-a[i].l){
ans+=(a[i].r-a[i].l)*a[i].v;
m-=(a[i].r-a[i].l);
}
else{
ans+=m*a[i].v;
m=0;
}
if(!m) break;
}
cout<<ans+m*a[1].v<<"\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
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: 0ms
memory: 3540kb
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: 0ms
memory: 3540kb
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'