# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
796498 | vjudge1 | Cover (COCI18_cover) | C++17 | 25 ms | 524 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define int long long
//#define ld long double
using namespace std;
using ll=long long;
const int inf = 2e18;
const int MN = 5e3+5;
const int mod=998244353;
int n;
pii a[MN];
int dp[MN];
inline void solve() {
cin>>n;
for (int i=1; i<=n; i++) {
cin>>a[i].fi>>a[i].se;
a[i].fi=abs(a[i].fi);
a[i].se=abs(a[i].se);
}
sort(a+1,a+n+1);
// build(1,1,n);
for (int i=1; i<=n; i++) dp[i]=inf;
for (int i=1; i<=n; i++) {
int mx=-inf, mn=inf;
for (int j=i; j>=1; j--) {
mx=max(mx,a[j].se);
mn=min(mn,a[j].se);
dp[i]=min(dp[i],dp[j-1]+a[i].fi*2*mx*2);
}
}
cout<<dp[n];
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t=1;
// preprocess();
// cin>>t;
while(t--) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |