QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#694034#9529. Farm Managementxiey#WA 0ms3620kbC++231.4kb2024-10-31 17:08:422024-10-31 17:08:46

Judging History

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

  • [2024-10-31 17:08:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3620kb
  • [2024-10-31 17:08:42]
  • 提交

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());
    ll ma=0,pos=0;
    for (int i = 0; i < n; i++)
    {
        if(ma<(a.back().first-a[i].first)*a[i].second.first)
        {
            ma=(a.back().first-a[i].first)*a[i].second.first;
            pos=i;
        }
    }
    ll a1 = sum + (m - num) * a.back().first;
    ll a2 = sum - a[pos].first * a[pos].second.first;
    m -= num - a[pos].second.first;
    for (int i = n - 1; i >= 0; i--)
    {
        if (i == pos)
            continue;
        if (m < a[i].second.second - a[i].second.first)
        {
            a2 += m * a[i].first;
            m = 0;
            break;
        }
        else
        {
            a2 += (a[i].second.second - a[i].second.first) * a[i].first;
            m -= a[i].second.second - a[i].second.first;
        }
    }
    // 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: 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: -100
Wrong Answer
time: 0ms
memory: 3604kb

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:

34859047

result:

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