QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#692164#9529. Farm ManagementranxiWA 0ms3604kbC++141.2kb2024-10-31 13:56:022024-10-31 13:56:03

Judging History

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

  • [2024-10-31 13:56:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3604kb
  • [2024-10-31 13:56:02]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define alls(x) x.begin(),x.end()
#define ull unsigned long long
#define lowbit(x) x&-x
#define lc p<<1
#define rc p<<1|1
#define PII pair<int,int>
#define vi vector<int>
//#define int long long

using namespace std;
const ll inf = 2e18;
const int mod = 998244353;
const int N = 1e6+10;
struct node{
    int w,l,r;
    bool operator<(node const &o)const{
        return w<o.w;
    }
};
void solve()
{
    int n;
    ll m;
    cin >> n>> m;
    vector<node>a(n);
    for(int i = 0;i<n;i++)
    {
        cin >> a[i].w >> a[i].l>>a[i].r;
    }
    sort(alls(a));
    ll ans = 0;
    for(int i = n-1;i>=0;i--)
    {
        if(a[i].l>m)
        {
            ans += m*a[i].w; 
            m = 0;
            break;
        }
        else if(m<a[i].r)
        {
            ans += m*a[i].w;
            m = 0;
            break;
        }
        else
        {
            ans += 1ll*a[i].r*a[i].w;
            m -= a[i].r;
        }
    }
    cout<<ans<<'\n';
}
signed main()
{
    cout<<fixed<<setprecision(6);
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
    int _ = 1;
    // cin >> _;
    while(_--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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:

40106857

result:

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