# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
440782 | bonopo | Cover (COCI18_cover) | C++14 | 98 ms | 588 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |