Submission #3209161


Source Code Expand

#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#include<bitset>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
struct node{int x,y;}a[214514];
multiset<int> S1,S2;
bool cmp(node x,node y){return x.x<y.x;}
int ans=0;
signed main(){
    int n;
    cin>>n;
    if (n==1)  {puts("0");  return 0;}
    for (int i=1; i<=n; i++)
    {
        cin>>a[i].x>>a[i].y;
        if (a[i].x>a[i].y)  swap(a[i].x,a[i].y);
        S1.insert(a[i].x),S2.insert(a[i].y);
    }
    ans=1LL*(*S1.rbegin()-*S1.begin())*(*S2.rbegin()-*S2.begin());
    sort(a+1,a+n+1,cmp);
    for (int i=1; i<=n; i++)
    {
        S1.erase(S1.find(a[i].x)),S1.insert(a[i].y);
        S2.erase(S2.find(a[i].y)),S2.insert(a[i].x);
        ans=min(ans,1LL*(*S1.rbegin()-*S1.begin())*(*S2.rbegin()-*S2.begin()));
    }
    cout<<ans<<endl;
    return 0;
}

Submission Info

Submission Time
Task E - Ball Coloring
User birdway
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1336 Byte
Status AC
Exec Time 631 ms
Memory 22144 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 35
Set Name Test Cases
Sample example0, example1, example2
All div20, div21, div22, div23, div24, example0, example1, example2, maxrand0, maxrand1, maxrand2, maxrand20, maxrand21, maxrand210, maxrand211, maxrand22, maxrand23, maxrand24, maxrand25, maxrand26, maxrand27, maxrand28, maxrand29, maxrand3, maxrand4, smallrand0, smallrand1, smallrand2, smallrand3, smallrand4, sparse0, sparse1, sparse2, sparse3, sparse4
Case Name Status Exec Time Memory
div20 AC 594 ms 22144 KB
div21 AC 594 ms 22144 KB
div22 AC 591 ms 22144 KB
div23 AC 599 ms 22144 KB
div24 AC 588 ms 22144 KB
example0 AC 1 ms 256 KB
example1 AC 1 ms 256 KB
example2 AC 1 ms 256 KB
maxrand0 AC 588 ms 22144 KB
maxrand1 AC 610 ms 22144 KB
maxrand2 AC 604 ms 22144 KB
maxrand20 AC 544 ms 22144 KB
maxrand21 AC 591 ms 22144 KB
maxrand210 AC 491 ms 22144 KB
maxrand211 AC 577 ms 22144 KB
maxrand22 AC 600 ms 22144 KB
maxrand23 AC 620 ms 22144 KB
maxrand24 AC 590 ms 22144 KB
maxrand25 AC 572 ms 22144 KB
maxrand26 AC 554 ms 22144 KB
maxrand27 AC 615 ms 22144 KB
maxrand28 AC 596 ms 22144 KB
maxrand29 AC 589 ms 22144 KB
maxrand3 AC 591 ms 22144 KB
maxrand4 AC 602 ms 22144 KB
smallrand0 AC 1 ms 256 KB
smallrand1 AC 1 ms 256 KB
smallrand2 AC 1 ms 256 KB
smallrand3 AC 1 ms 256 KB
smallrand4 AC 1 ms 256 KB
sparse0 AC 614 ms 22144 KB
sparse1 AC 631 ms 22144 KB
sparse2 AC 606 ms 22144 KB
sparse3 AC 606 ms 22144 KB
sparse4 AC 609 ms 22144 KB