Submission #147245

#TimeUsernameProblemLanguageResultExecution timeMemory
147245SeekingOblivionCover (COCI18_cover)C++14
120 / 120
11 ms504 KiB
//#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 timeMemoryGrader output
Fetching results...