Submission #13817699


Source Code Expand

Copy
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n;
    cin >> n;
    ll a[n], b[n];
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    sort(a,a+n);
    sort(b,b+n);

    ll ans = 0;

    if(n % 2 == 1){
        ans = b[n/2] - a[n/2] + 1;
    }else{
        ans = (b[n/2]+b[n/2-1]) - (a[n/2]+a[n/2-1]) + 1;
    }

    cout << ans << endl;
    return 0;
}



Submission Info

Submission Time
Task E - Count Median
User Shibuyap
Language C++ (GCC 9.2.1)
Score 500
Code Size 671 Byte
Status AC
Exec Time 143 ms
Memory 6764 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status AC
AC × 25
Set Name Test Cases
Sample
All handmade02, handmade03, handmade04, handmade05, handmade06, handmade07, handmade08, handmade09, handmade10, handmade11, handmade12, handmade13, handmade14, handmade15, handmade16, handmade17, random18, random19, random20, random21, random22, random23, random24, sample00, sample01
Case Name Status Exec Time Memory
handmade02 AC 3 ms 3392 KB
handmade03 AC 2 ms 3588 KB
handmade04 AC 2 ms 3448 KB
handmade05 AC 4 ms 3592 KB
handmade06 AC 3 ms 3572 KB
handmade07 AC 2 ms 3436 KB
handmade08 AC 2 ms 3624 KB
handmade09 AC 2 ms 3568 KB
handmade10 AC 2 ms 3440 KB
handmade11 AC 2 ms 3528 KB
handmade12 AC 92 ms 6692 KB
handmade13 AC 92 ms 6648 KB
handmade14 AC 142 ms 6536 KB
handmade15 AC 139 ms 6564 KB
handmade16 AC 119 ms 6524 KB
handmade17 AC 121 ms 6764 KB
random18 AC 33 ms 4240 KB
random19 AC 76 ms 5084 KB
random20 AC 143 ms 6684 KB
random21 AC 140 ms 6652 KB
random22 AC 2 ms 3412 KB
random23 AC 87 ms 5392 KB
random24 AC 69 ms 4960 KB
sample00 AC 2 ms 3592 KB
sample01 AC 2 ms 3572 KB