| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 142641 | Ruxandra985 | Cover (COCI18_cover) | C++14 | 25 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 <cstdio>
#include <iostream>
#include <algorithm>
#define DIMN 5010
using namespace std;
long long d[DIMN];
struct punct {
    int x,y;
} v[DIMN];
int cmp (punct a , punct b){
    if (a.x != b.x)
        return a.x < b.x;
    return a.y < b.y;
}
int main()
{
    //FILE *fin = fopen ("a.in","r");
    //FILE *fout = fopen ("a.out","w");
    int n,i,ymax,j;
    scanf ("%d",&n);
    for (i=1;i<=n;i++){
        scanf ("%d%d",&v[i].x , &v[i].y);
        v[i].x = max (v[i].x , -v[i].x);
        v[i].y = max (v[i].y , -v[i].y);
    }
    sort (v+1 , v+n+1 , cmp);
    for (i=1;i<=n;i++){
        ymax = -1;
        d[i] = 1000000000000000000;
        for (j = i-1; j>=0 ; j--){
            ymax = max(ymax , v[j+1].y);
            /// de la j+1 .. i , un nou dreptunghi
            d[i] = min (d[i] , d[j] + (long long)ymax * v[i].x);
        }
    }
    printf ( "%lld" , d[n] * 4);
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
