QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#469320#9101. Zayin and BusBingeWA 0ms3824kbC++14803b2024-07-09 17:28:572024-07-09 17:28:57

Judging History

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

  • [2024-07-09 17:28:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3824kb
  • [2024-07-09 17:28:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int long long

const int N=1e4+10;
pair<int,int>p[N];
int dp[N],g[N];

signed main()
{
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

	int n,V,k;
	cin>>n>>V>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>p[i].first>>p[i].second;
	}
	sort(p+1,p+n+1);
	priority_queue<int, vector<int>, greater<int>>q;
	int ans1=0;
	for(int i=n;i>0;i--)
	{
		q.push(p[i].second);
        ans1 += p[i].second;
        if (q.size() > k) {
            ans1 -= q.top();
            q.pop();
        }
        g[i] = ans1;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=V;j>=p[i].first;j--)
		{
			dp[j]=max(dp[j-p[i].first]+p[i].second,dp[j]);
			ans=max(g[i+1]+dp[j],ans);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3824kb

input:

14
1
1
1
2
1
3
2
1
1 1
2
1
1 2
2
1
2 1
2
1
1 3
2
1
3 1
2
1
1 4
2
1
4 1
3
1 1
1 1 1
3
1 2
1 1 1
3
1 1
1 3 2
3
1 2
1 3 2

output:

7

result:

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