QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#693504#9529. Farm Managementxiey#WA 0ms3648kbC++231.4kb2024-10-31 16:17:302024-10-31 16:17:39

Judging History

你现在查看的是最新测评结果

  • [2024-10-31 16:17:39]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3648kb
  • [2024-10-31 16:17:30]
  • 提交

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;
        }
    sort(a.begin(),a.end());
    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(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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3648kb

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: 3616kb

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:

34629658

result:

wrong answer 1st lines differ - expected: '35204500', found: '34629658'