답안 #440132

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
440132 2021-07-01T16:02:41 Z julian33 Cover (COCI18_cover) C++14
120 / 120
29 ms 396 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
    cerr<<vars<<" = ";
    string delim="";
    (...,(cerr<<delim<<values,delim=", "));
    cerr<<"\n";
}
#else
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {}
#endif

#define pb push_back
#define sz(x) (int)(x.size())
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> inline void maxa(T& a,T b){a=max(a,b);}
template<typename T> inline void mina(T& a,T b){a=min(a,b);} 

const int mxN=5e3+5;

pll pts[mxN];
ll dp[mxN];

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int n; cin>>n;
    for(int i=1;i<=n;i++){
        cin>>pts[i].first>>pts[i].second;
        pts[i].first=abs(pts[i].first);
        pts[i].second=abs(pts[i].second);
    }
    fill(dp+1,dp+1+n,1e16);
    sort(pts+1,pts+1+n);
    for(int i=1;i<=n;i++){
        ll cx=pts[i].first;
        ll cy=pts[i].second;
        for(int j=i-1;j>=0;j--){
            mina(dp[i],4*cx*cy+dp[j]);
            maxa(cx,pts[j].first);
            maxa(cy,pts[j].second);
        }
    }
    cout<<dp[n]<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 252 KB Output is correct
9 Correct 11 ms 396 KB Output is correct
10 Correct 29 ms 332 KB Output is correct