# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
144992 | Linca_Robert | Cover (COCI18_cover) | C++14 | 29 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int DIM = 5e4 + 5;
int N;
long long dp[DIM];
pair<int,int> arr[DIM];
int main(){
cin >> N;
for( int i = 1; i <= N; i++ ){
cin >> arr[i].first >> arr[i].second;
if( arr[i].first < 0 ) arr[i].first *= (-1);
if( arr[i].second < 0 ) arr[i].second *= (-1);
}
sort( arr + 1, arr + N + 1 );
for( int i = 1; i <= N; i++ ){
dp[i] = (1LL<<61);
int H = 0;
for( int j = i; j >= 1; j-- ){
H = max( H, arr[j].second );
dp[i] = min( dp[i], dp[j - 1] + 4LL * arr[i].first * H );
}
}
cout << dp[N] << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |