# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
89877 | vex | Cover (COCI18_cover) | C++14 | 16 ms | 812 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define maxn 5005
#define pii pair<long long,long long>
#define x first
#define y second
using namespace std;
int n;
pii a[maxn];
pii sol[maxn];
bool veci(pii p1,pii p2)
{
return p1.x>=p2.x && p1.y>=p2.y;
}
long long dp[maxn];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i].x>>a[i].y;
if(a[i].x<0)a[i].x=-a[i].x;
if(a[i].y<0)a[i].y=-a[i].y;
}
sort(a,a+n);
int len=0;
for(int i=0;i<n;i++)
{
bool bit=true;
for(int j=i+1;j<n;j++)
{
if(veci(a[j],a[i]))bit=false;
}
if(bit)
{
len++;
sol[len]=a[i];
}
}
//for(int i=1;i<=len;i++)cout<<sol[i].x<<","<<sol[i].y<<" ";cout<<endl;
dp[0]=0LL;
for(int i=1;i<=len;i++)
{
dp[i]=dp[i-1]+4*sol[i].x*sol[i].y;
for(int j=1;j<i;j++)
{
long long tre=dp[j-1]+4*sol[i].x*sol[j].y;
if(tre<dp[i])dp[i]=tre;
}
}
//for(int i=0;i<=len;i++)cout<<dp[i]<<" ";cout<<endl;
cout<<dp[len]<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |