QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#672969#9529. Farm Managementucup-team4474#WA 1ms3960kbC++201.8kb2024-10-24 20:05:242024-10-24 20:05:24

Judging History

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

  • [2024-10-24 20:05:24]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3960kb
  • [2024-10-24 20:05:24]
  • 提交

answer

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<vector>
#include<bitset>
#include<random>
#include<ctime>
#include<queue>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long,long long>
#define FF fflush(stdout)
#define inf 0x3f3f3f3f
#define endl "\n"
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
//char buf[1<<20],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline ll read()
{
    ll s=0,f=1;
    char x=getchar();
    while(!isdigit(x))f=(x=='-'?-1:1),x=getchar();
    while(isdigit(x))s=s*10+x-'0',x=getchar();
    return s*f;
}
const int p=1e9+7;
//ll ksm(int a,int b){ll ans=1,bs=a;while(b){if(b&1)ans=ans*bs%p;bs=bs*bs%p;b>>=1;}return ans;}
mt19937 rd(time(0));
#define reaD read
struct hlydl{
    ll w,l,r;
}t[100005];
ll res[100005];
int main()
{
    int n=reaD();
    ll m=read();
    for(int i=1;i<=n;i++)
    {
        int w=reaD(),l=reaD(),r=reaD();
        t[i]=(hlydl){w,l,r};
    }
    sort(t+1,t+n+1,[](hlydl x,hlydl y){
        return x.w<y.w;
    });
    ll ans=0,anss=0;
    for(int i=1;i<=n;i++)
    ans+=t[i].l*t[i].w,m-=t[i].l;
    int now=n;
    for(int i=n;i>=1;i--)
    {
        ans-=t[i].l*t[i].w;
        m+=t[i].l;
        while(m&&now>i)
        {
            ll del=min(m,res[now]);
            res[now]-=del;
            m-=del;
            ans+=t[now].w*del;
            if(!res[now])now--;
        }
        anss=max(anss,ans+m*t[i].w);
        res[i]=t[i].r;
    }
    printf("%lld",anss);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3804kb

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

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'