QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#420434#8641. Ski 2flying0 1ms5368kbC++141.4kb2024-05-24 18:10:332024-05-24 18:10:39

Judging History

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

  • [2024-05-24 18:10:39]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:5368kb
  • [2024-05-24 18:10:33]
  • 提交

answer

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

#define int long long

const int N=305;

int a[N], cost[N], pos[N], sum[N], Min[N];
int dp1[N][N], dp2[N][N];
map <int,int> cnt, have, Mincost;

signed main()
{
	int n,m,K;
	cin >> n >> K;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld %lld",&a[i],&cost[i]);
		cnt[a[i]]++;
		have[a[i]]++;
		if(have[a[i]]>1)
			Mincost[a[i]]=min(Mincost[a[i]],cost[i]);
		else
			Mincost[a[i]]=cost[i];

		int pos=a[i];
		while(cnt[pos]>=2)
		{
			cnt[pos]--;
			pos++;
			cnt[pos]++;
		}
	}

	int indx=0;
	for(auto x:cnt)
		pos[++indx]=x.first;
	n=indx;

	Min[0]=1e12;
	for(int i=1;i<=n;i++)
	{
		a[i]=have[pos[i]];
		if(a[i])
		{
			sum[i]=sum[i-1]+a[i];
			Min[i]=min(Min[i-1],Mincost[pos[i]]);
		}
		else
			sum[i]=sum[i-1], Min[i]=Min[i-1];
	}

	memset(dp2,0x3f,sizeof(dp2));
	dp2[0][1]=0;
	for(int i=1;i<=n;i++) //目前到第i层
	{
		memset(dp1,0x3f,sizeof(dp1));
		for(int cnt=a[i];cnt<=sum[i];cnt++)
			for(int Max=1;Max<=sum[i];Max++)
				dp1[cnt][Max]=dp2[cnt-a[i]][Max];

		memset(dp2,0x3f,sizeof(dp2));
		for(int cnt=0;cnt<=sum[i];cnt++)
			for(int Max=1;Max<=sum[i];Max++)
				for(int j=1;j<=Max;j++)
				{
					dp2[cnt][Max]=min(dp2[cnt][Max],dp1[cnt+j][Max]+cnt*K);
					dp2[cnt][Max]=min(dp2[cnt][Max],dp1[cnt+Max][j]+cnt*K+(Max-j)*Min[i-1]);
				}
	}

	int ans=0x3f3f3f3f3f3f3f3f;
	for(int i=1;i<=n;i++)
		ans=min(ans,dp2[0][i]);
	printf("%lld\n",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

300 987761245
249 97
279 38
52 53
190 2
294 46
170 93
260 70
273 6
49 4
32 71
188 28
212 10
253 86
187 46
167 27
32 75
226 90
86 17
172 24
129 70
291 78
189 98
97 98
256 19
228 36
240 86
240 63
269 21
81 81
41 25
155 49
279 12
176 49
136 25
260 95
271 90
202 79
299 36
79 53
297 59
46 92
202 19
125 3...

output:


result:


Subtask #2:

score: 0
Runtime Error

Test #9:

score: 0
Runtime Error

input:

300 1
0 6596366
1 195480684
2 39457151
1 832234727
1 462764495
2 81049898
0 487070027
1 430671894
2 721333033
1 615885993
1 842070560
1 592116125
2 840818824
0 544935711
2 333187430
2 467111553
0 416912849
2 159079860
0 478546939
0 593053374
0 876528192
2 9215174
1 93255151
2 120891934
0 10339332
2 ...

output:


result:


Subtask #3:

score: 0
Wrong Answer

Test #20:

score: 0
Wrong Answer
time: 1ms
memory: 5368kb

input:

10 849097758
4 937762392
10 817247459
0 440668594
1 912982987
7 663812156
7 594886472
0 837105766
2 737473115
3 649275922
10 873042888

output:

5943684306

result:

wrong answer 1st lines differ - expected: '1289766352', found: '5943684306'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%