# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
239012 |
2020-06-14T06:50:05 Z |
VEGAnn |
Cover (COCI18_cover) |
C++14 |
|
7 ms |
512 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
7 ms |
512 KB |
Output is correct |