QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#814092 | #9879. ReTravel | ucup-team3510# | WA | 56ms | 7980kb | C++20 | 898b | 2024-12-14 15:09:43 | 2024-12-14 15:09:48 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define s1 first
#define s2 second
using namespace std;
ll dp[511][511];int mnx[511][511],mny[511][511];int n;
pii a[511];
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;++i)scanf("%d%d",&a[i].s1,&a[i].s2);
sort(a+1,a+1+n);
memset(dp,0x3f,sizeof(dp));
for(int i=1;i<=n;++i)dp[i][i]=0;
for(int l=1;l<=n;++l)
{
mnx[l][l]=a[l].s1;
mny[l][l]=a[l].s2;
for(int r=l+1;r<=n;++r)mnx[l][r]=min(mnx[l][r-1],a[r].s1),mny[l][r]=min(mny[l][r-1],a[r].s2);
}
for(int i=2;i<=n;++i)
{
for(int l=1;l+i-1<=n;++l)
{
int r=l+i-1;
for(int k=l;k<r;++k)
{
dp[l][r]=min(dp[l][r],dp[l][k]+dp[k+1][r]
+mny[l][k]+mnx[k+1][r]+mnx[l][k]+mny[k+1][r]-2ll*(mny[l][r]+mnx[l][r]));
}
// printf("dp[%d,%d]:%lld\n",l,r,dp[l][r]);
}
}
printf("%lld\n",dp[1][n]+mnx[1][n]+mny[1][n]);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7196kb
input:
2 3 3 1 2
output:
6
result:
ok "6"
Test #2:
score: 0
Accepted
time: 1ms
memory: 7876kb
input:
3 2 2 3 3 1 3
output:
7
result:
ok "7"
Test #3:
score: -100
Wrong Answer
time: 56ms
memory: 7980kb
input:
500 906691059 413653999 813847339 955892128 451585301 43469773 278009742 548977048 521760889 434794718 985946604 841597326 891047768 325679554 511742081 384452587 626401695 957413342 975078788 234551094 541903389 149544006 302621084 150050891 811538590 101823753 663968655 858351976 268979133 9768326...
output:
91530172732
result:
wrong answer 1st words differ - expected: '202616034783', found: '91530172732'