답안 #340317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
340317 2020-12-27T12:24:48 Z Ahmad_Hasan Cover (COCI18_cover) C++17
36 / 120
2 ms 492 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Incorrect 1 ms 364 KB Output isn't correct
7 Incorrect 1 ms 364 KB Output isn't correct
8 Incorrect 1 ms 364 KB Output isn't correct
9 Incorrect 2 ms 364 KB Output isn't correct
10 Incorrect 2 ms 492 KB Output isn't correct