Submission #13826720


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <algorithm>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;

    std::vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) std::cin >> a[i] >> b[i];

    std::sort(a.begin(), a.end());
    std::sort(b.begin(), b.end());

    if (n % 2) {
        std::cout << b[n / 2] - a[n / 2] + 1 << std::endl;
    } else {
        const i64 l = a[n / 2 - 1] + a[n / 2],
            r = b[n / 2 - 1] + b[n / 2];
        std::cout << r - l + 1 << std::endl;
    }

    return 0;
}

Submission Info

Submission Time
Task E - Count Median
User CharlotteL
Language C++ (GCC 9.2.1)
Score 500
Code Size 560 Byte
Status AC
Exec Time 145 ms
Memory 4780 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 4 ms 3600 KB
handmade03 AC 2 ms 3524 KB
handmade04 AC 2 ms 3492 KB
handmade05 AC 1 ms 3472 KB
handmade06 AC 1 ms 3632 KB
handmade07 AC 2 ms 3628 KB
handmade08 AC 2 ms 3492 KB
handmade09 AC 2 ms 3416 KB
handmade10 AC 2 ms 3496 KB
handmade11 AC 2 ms 3468 KB
handmade12 AC 97 ms 4688 KB
handmade13 AC 97 ms 4752 KB
handmade14 AC 145 ms 4780 KB
handmade15 AC 143 ms 4628 KB
handmade16 AC 119 ms 4748 KB
handmade17 AC 120 ms 4608 KB
random18 AC 34 ms 3596 KB
random19 AC 82 ms 3972 KB
random20 AC 140 ms 4612 KB
random21 AC 144 ms 4748 KB
random22 AC 2 ms 3492 KB
random23 AC 82 ms 3836 KB
random24 AC 69 ms 4048 KB
sample00 AC 2 ms 3488 KB
sample01 AC 2 ms 3416 KB