# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
750260 | bgnbvnbv | Cover (COCI18_cover) | C++14 | 15 ms | 468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define TASKNAME "codeforce"
#define pb push_back
#define pli pair<ll,ll>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxN=2e5;
const ll inf=1e18;
const ll mod=1e9+7;
ll n;
ll dp[maxN];
struct qq
{
ll a,b;
bool operator<(const qq&o)
{
return a*b<o.a*o.b;
}
}x[maxN];
vector<pli>vec;
void solve()
{
cin >> n;
ll ans=0;
for(int i=1;i<=n;i++)
{
cin >> x[i].a >> x[i].b;
x[i].a=abs(x[i].a);
x[i].b=abs(x[i].b);
ans+=x[i].a*x[i].b;
}
sort(x+1,x+n+1);
for(int i=1;i<=n;i++)
{
bool ok=true;
for(int j=i+1;j<=n;j++)
{
if(x[i].a<=x[j].a&&x[i].b<=x[j].b)
{
ok=false;
break;
}
}
if(ok)vec.pb({x[i].a,x[i].b});
}
sort(vec.begin(),vec.end());
dp[0]=0;
for(int i=0;i<vec.size();i++)
{
dp[i+1]=inf;
for(int j=-1;j<i;j++)
{
dp[i+1]=min(dp[i+1],dp[j+1]+vec[j+1].se*vec[i].fi);
}
}
cout <<dp[vec.size()]*4;
}
int main()
{
fastio
//freopen(TASKNAME".INP","r",stdin);
//freopen(TASKNAME".OUT","w",stdout);
solve();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |