QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#420441 | #8641. Ski 2 | flying | 0 | 1312ms | 5420kb | C++14 | 1.6kb | 2024-05-24 18:15:58 | 2024-05-24 18:16:02 |
Judging History
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()
{
// freopen("1.in","r",stdin);
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++)
{
if(cnt+j<=sum[i])
dp2[cnt][Max]=min(dp2[cnt][Max],dp1[cnt+j][Max]);
if(cnt+Max<=sum[i])
dp2[cnt][Max]=min(dp2[cnt][Max],dp1[cnt+Max][j]+(Max-j)*Min[i-1]);
}
dp2[cnt][Max] += cnt*K;
}
}
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
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1312ms
memory: 5420kb
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:
1716729043810
result:
wrong answer 1st lines differ - expected: '144', found: '1716729043810'
Subtask #2:
score: 0
Time Limit Exceeded
Test #9:
score: 0
Time Limit Exceeded
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%