# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
340317 | Ahmad_Hasan | Cover (COCI18_cover) | C++17 | 2 ms | 492 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |