# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147245 | SeekingOblivion | Cover (COCI18_cover) | C++14 | 11 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#include<fstream>
#include<queue>
#include<algorithm>
#include<iostream>
#define fin cin
#define fout cout
using namespace std;
//ifstream fin("date.in");
//ofstream fout("date.out");
int i,a,b,n,m,j;
long long sol[5010];
pair<int,int> v[5010],d[5010];
int main()
{
fin>>n;
for(i=1;i<=n;i++)
{
fin>>a>>b;
if(a<0) a=-a;
if(b<0) b=-b;
v[i].first=a;v[i].second=b;
}
sort(v+1,v+n+1);
for(i=1;i<=n;i++)
{
while(m>0&&d[m].second<v[i].second) m--;
d[++m]=v[i];
}
for(i=1;i<=m;i++) sol[i]=9223372036854775807;
for(i=1;i<=m;i++)
for(j=i;j>=1;j--)
sol[i]=min(sol[j-1]+1LL*d[i].first*d[j].second,sol[i]);
fout<<sol[m]*4;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |