# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
796498 |
2023-07-28T12:46:04 Z |
vjudge1 |
Cover (COCI18_cover) |
C++17 |
|
25 ms |
524 KB |
#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 |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
9 ms |
380 KB |
Output is correct |
10 |
Correct |
25 ms |
524 KB |
Output is correct |