Submission #13798056


Source Code Expand

Copy
#include<bits/stdc++.h>

using namespace std;

int const maxn = 2e5 + 5;
int a[maxn], b[maxn];

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i] >> b[i];
    }
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    if (n % 2 == 1) cout << b[(n + 1) / 2] - a[(n + 1) / 2] + 1 << '\n';
    else cout << (b[n / 2] + b[n / 2 + 1] - a[n / 2] - a[n / 2 + 1]) + 1 << '\n';
    return 0;
}

Submission Info

Submission Time
Task E - Count Median
User traktor74
Language C++ (GCC 9.2.1)
Score 500
Code Size 595 Byte
Status AC
Exec Time 63 ms
Memory 5220 KB

Compile Error

./Main.cpp:8:6: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    8 | main() {
      |      ^
./Main.cpp: In function ‘int main()’:
./Main.cpp:15:12: warning: unused variable ‘ans’ [-Wunused-variable]
   15 |     int n, ans = 0;
      |            ^~~

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 7 ms 3548 KB
handmade03 AC 2 ms 3548 KB
handmade04 AC 2 ms 3548 KB
handmade05 AC 2 ms 3480 KB
handmade06 AC 2 ms 3548 KB
handmade07 AC 2 ms 3524 KB
handmade08 AC 2 ms 3592 KB
handmade09 AC 2 ms 3588 KB
handmade10 AC 2 ms 3616 KB
handmade11 AC 2 ms 3528 KB
handmade12 AC 34 ms 5176 KB
handmade13 AC 36 ms 5172 KB
handmade14 AC 58 ms 5104 KB
handmade15 AC 63 ms 5220 KB
handmade16 AC 40 ms 5052 KB
handmade17 AC 40 ms 5056 KB
random18 AC 20 ms 3888 KB
random19 AC 35 ms 4396 KB
random20 AC 59 ms 5108 KB
random21 AC 61 ms 5132 KB
random22 AC 3 ms 3664 KB
random23 AC 37 ms 4448 KB
random24 AC 30 ms 4340 KB
sample00 AC 4 ms 3592 KB
sample01 AC 2 ms 3620 KB