답안 #440782

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
440782 2021-07-03T02:04:30 Z bonopo Cover (COCI18_cover) C++14
120 / 120
98 ms 588 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define el "\n"
#define f first
#define s second

typedef long long ll;
const int MM=5e3+5, MOD=1e9+7;
ll N, dp[MM];
vector<pair<ll,ll>> pta, ptb;

int32_t main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    cin>>N;
    for(int i=1, x, y; i<=N; ++i) {
        cin>>x>>y; pta.pb({abs(x), abs(y)}); }
    for(auto &a:pta) {
        bool g=1;
        for(auto &b:pta)
            if(b.f>a.f&&b.s>a.s) g=0;
        if(g) ptb.pb(a); }
    sort(begin(ptb), end(ptb));
    memset(dp, 0x3f, sizeof(dp)); dp[0]=0;
    for(int i=0; i<ptb.size(); ++i) {
        ll c=i+1, mh=0;
        for(int j=i; j>=0; --j) {
            mh=max(mh, ptb[j].s);
            dp[c]=min(dp[c], dp[j]+ptb[i].f*mh); }
    } cout<<dp[ptb.size()]*4LL<<el;
}

// MM

Compilation message

cover.cpp: In function 'int32_t main()':
cover.cpp:27:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0; i<ptb.size(); ++i) {
      |                  ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 6 ms 416 KB Output is correct
9 Correct 36 ms 468 KB Output is correct
10 Correct 98 ms 588 KB Output is correct