Submission #340317

#TimeUsernameProblemLanguageResultExecution timeMemory
340317Ahmad_HasanCover (COCI18_cover)C++17
36 / 120
2 ms492 KiB
#include <bits/stdc++.h> using namespace std; bool comp(pair<int,int>a,pair<int,int>b){ if(a.first==b.first) return a.second>b.second; return a.first>b.first; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; vector<pair<long long,long long> >vps(n); for(int i=0;i<n;i++){ cin>>vps[i].first>>vps[i].second; vps[i].first=abs(vps[i].first); vps[i].second=abs(vps[i].second); } sort(vps.begin(),vps.end(),comp); long long ans=0ll; long long x=vps[0].first,y=vps[0].second; for(int i=0;i<n;i++){ if(vps[i].second>y){ if(vps[i].second*vps[i].first+x*y<max(y,vps[i].second)*max(x,vps[i].first)){ ans+=x*y; x=vps[i].first; y=vps[i].second; }else{ x=max(x,vps[i].first); y=max(y,vps[i].second); } } if(i==n-1) ans+=x*y; } cout<<4ll*ans<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...