QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#693472 | #9529. Farm Management | xiey# | WA | 0ms | 3848kb | C++23 | 1.4kb | 2024-10-31 16:13:44 | 2024-10-31 16:13:47 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
ll n, m;
cin >> n >> m;
vector<pair<ll, pair<ll, ll>>> a(n);
ll sum=0,num=0;
for (int i = 0; i < n; i++)
{
cin >> a[i].first >> a[i].second.first >> a[i].second.second;
sum+=a[i].second.first*a[i].first;
num+=a[i].second.first;
}
vector<pair<long double,int>> b(n);
for(int i=0;i<n;i++)
{
b[i]={1.0*a[i].first/a[i].second.first,i};
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
ll a1 = sum+(m-num)*a.back().first;
ll a2=sum-a[b[0].second].first*a[b[0].second].second.first;
m-=num-a[b[0].second].second.first;
while (m)
{
auto p = b.back();
if (m < a[p.second].second.second-a[p.second].second.first)
{
a2 += m * a[p.second].first;
m = 0;
}
else
{
a2 += (a[p.second].second.second-a[p.second].second.first) * a[p.second].first;
m -= a[p.second].second.second-a[p.second].second.first;
}
b.pop_back();
}
// cout<<a1<<' '<<a2<<'\n';
cout << max(a1,a2);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin>>t;
while (t--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3848kb
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: 0ms
memory: 3808kb
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:
31758380
result:
wrong answer 1st lines differ - expected: '35204500', found: '31758380'