Submission #145155

# Submission time Handle Problem Language Result Execution time Memory
145155 2019-08-18T22:53:58 Z mihaican Cover (COCI18_cover) C++14
24 / 120
18 ms 2040 KB
#include <iostream>
#include <set>
#define dd 20010
using namespace std;
struct puncte {
    long long x;
    long long y;
}v[dd];
struct dr{
    long long dx;
    long long dy;
}v2[dd];
set<pair<long long,long long>>sset;
long long n,n2,x,y,k, minim, maxim, sol,d[dd],uituc;
int main(){
/*
6
1 20
3 17
5 15
8 12
9 11
10 10
*/
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>x>>y;
        sset.insert(make_pair(x,y));
        sset.insert(make_pair(-x,y));
        sset.insert(make_pair(x,-y));
        sset.insert(make_pair(-x,-y));
    }
    for(set<pair<long long, long long> >::iterator it = sset.begin();it!=sset.end();it++)
        v[++n2].x=it->first,v[n2].y =it->second;
    minim=v[1].y;
    maxim=v[1].y;
    for(long long i=2;i<=n2;i++){
        uituc=i;
        if(v[i].x>=0)
            break;
        if(v[i].x==v[i-1].x){
            maxim=max(maxim,v[i].y);
            minim=min(minim,v[i].y);
        }
        else{
            if(maxim-minim>v2[k].dy||k==0){
                v2[++k].dx=-v[i-1].x*2;
                v2[k].dy=maxim-minim;
            }
            maxim=v[i].y;
            minim=v[i].y;
        }
    }



    //d[i]=suma min pt primele i triunghiuri



    for(long long i=1;i<=k;i++){
        d[i]=v2[1].dx*v2[i].dy;
        for(long long j=i;j>=1;j--)
            d[i]=min(d[j-1]+v2[j].dx*v2[i].dy,d[i]);
    }
    cout<<d[k];
}


# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Incorrect 3 ms 424 KB Output isn't correct
8 Incorrect 5 ms 632 KB Output isn't correct
9 Correct 10 ms 1272 KB Output is correct
10 Correct 18 ms 2040 KB Output is correct