제출 #239012

#제출 시각아이디문제언어결과실행 시간메모리
239012VEGAnnCover (COCI18_cover)C++14
120 / 120
7 ms512 KiB
#include <bits/stdc++.h> #define i2 array<int,2> #define PB push_back #define all(x) x.begin(),x.end() #define sz(x) ((int)x.size()) using namespace std; typedef long long ll; const int N = 5010; const ll OO = 1e18; vector<i2> vc; i2 a[N]; int x[N], y[N], n; ll f[N]; void upd(ll &x, ll y){ x = min(x, y); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef _LOCAL freopen("in.txt","r",stdin); #endif // _LOCAL cin >> n; for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1]; a[i][0] = abs(a[i][0]); a[i][1] = abs(a[i][1]); } sort(a, a + n); reverse(a, a + n); vc.PB(a[0]); for (int i = 1; i < n; i++) if (a[i][1] > vc.back()[1]) vc.PB(a[i]); reverse(all(vc)); f[0] = 0; n = sz(vc); fill(f + 1, f + n + 1, OO); for (int i = 0; i < n; i++) for (int j = i + 1; j <= n; j++) upd(f[j], f[i] + ll(vc[i][1]) * ll(vc[j - 1][0])); cout << f[n] * 4; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...