Submission #13811688


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for(int i=0; i<N; i++) cin >> A[i] >> B[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    int ans;
    if(N%2){
        int mx = B[N/2], mn = A[N/2];
        ans = mx-mn+1;
    }else{
        int mx = B[N/2-1] + B[N/2];
        int mn = A[N/2-1] + A[N/2];
        ans = mx-mn+1; 
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task E - Count Median
User betrue12
Language C++ (GCC 9.2.1)
Score 500
Code Size 485 Byte
Status AC
Exec Time 142 ms
Memory 4788 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 2 ms 3488 KB
handmade03 AC 2 ms 3472 KB
handmade04 AC 2 ms 3592 KB
handmade05 AC 2 ms 3632 KB
handmade06 AC 2 ms 3412 KB
handmade07 AC 3 ms 3496 KB
handmade08 AC 2 ms 3436 KB
handmade09 AC 2 ms 3432 KB
handmade10 AC 2 ms 3628 KB
handmade11 AC 2 ms 3416 KB
handmade12 AC 94 ms 4788 KB
handmade13 AC 98 ms 4684 KB
handmade14 AC 141 ms 4768 KB
handmade15 AC 142 ms 4612 KB
handmade16 AC 119 ms 4684 KB
handmade17 AC 122 ms 4604 KB
random18 AC 32 ms 3592 KB
random19 AC 77 ms 3868 KB
random20 AC 142 ms 4604 KB
random21 AC 140 ms 4604 KB
random22 AC 2 ms 3420 KB
random23 AC 87 ms 4048 KB
random24 AC 70 ms 3996 KB
sample00 AC 2 ms 3520 KB
sample01 AC 2 ms 3416 KB