Submission #144992

#TimeUsernameProblemLanguageResultExecution timeMemory
144992Linca_RobertCover (COCI18_cover)C++14
120 / 120
29 ms504 KiB
#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 timeMemoryGrader output
Fetching results...