답안 #142641

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
142641 2019-08-10T08:05:37 Z Ruxandra985 Cover (COCI18_cover) C++14
120 / 120
25 ms 504 KB
#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

cover.cpp: In function 'int main()':
cover.cpp:20:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d",&n);
     ~~~~~~^~~~~~~~~
cover.cpp:22:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d%d",&v[i].x , &v[i].y);
         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 11 ms 376 KB Output is correct
10 Correct 25 ms 504 KB Output is correct