QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#368083#3998. The ProfiteerGraphcityWA 1ms5804kbC++201.3kb2024-03-26 19:59:322024-03-26 19:59:32

Judging History

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

  • [2024-03-26 19:59:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5804kb
  • [2024-03-26 19:59:32]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rof(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int Maxn=2e5,inf=1e9+7;

int n,m,E,a[Maxn+5],b[Maxn+5],h[Maxn+5],ans[Maxn+5];
vector<vector<int>> v;

inline void Insert(int p)
{
    v.push_back(v.back());
    For(i,a[p],m) v.back()[i]=max(v.back()[i],v.back()[i-a[p]]+h[p]);
}
inline int Check()
{
    ll res=0; For(i,1,m) res+=v.back()[i];
    if(res>1ll*m*E) return 1; return 0;
}
inline void dfs(int l,int r,int ql,int qr)
{
    if(l>r || ql>qr) return;
    int mid=(l+r)>>1,pos=-1;
    For(i,l,mid) Insert(i);
    Rof(i,qr,max(mid+1,ql))
    {
        if(Check()) {pos=i; break;}
        Insert(i-1);
    } if(pos==-1) pos=mid; ans[mid]=pos;
    For(i,pos,qr-1) v.pop_back();
    dfs(mid+1,r,pos,qr);
    For(i,l,mid) v.pop_back();
    Rof(i,qr-1,pos) Insert(i);
    dfs(l,mid-1,ql,pos);
}

int main()
{
    // freopen("1.in","r",stdin);

    cin>>n>>m>>E;
    For(i,1,n) cin>>h[i]>>a[i]>>b[i];
    v.push_back(vector<int>(m+2,0));
    For(i,1,n) For(j,b[i],m) v[0][j]=max(v[0][j],v[0][j-b[i]]+h[i]);
    int it=n+1; while(!Check() && it) Insert(--it); ans[0]=it;
    while(v.size()>1) v.pop_back();
    dfs(1,n,1,n+1); ll all=0;
    For(i,0,n) all+=(n-max(ans[i],i+1)+1);
    cout<<all<<endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 5 3
3 2 4
1 2 3
2 1 2
3 1 3

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 1ms
memory: 5804kb

input:

4 5 4
3 2 4
1 2 3
2 1 2
3 1 3

output:

3

result:

ok single line: '3'

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 5596kb

input:

4 5 5
3 2 4
1 2 3
2 1 2
3 1 3

output:

3

result:

wrong answer 1st lines differ - expected: '7', found: '3'