# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
440782 | bonopo | Cover (COCI18_cover) | C++14 | 98 ms | 588 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 <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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |