Submission #13807428


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {
public:

	UL N;
	UL A[200000];
	UL B[200000];

	void Solve() {
		scanf("%u", &N);
		rep(i, N) scanf("%u%u", A + i, B + i);
		sort(A, A + N);
		sort(B, B + N);
		UL ans;
		if (N & 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;
	}
};

int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}

Submission Info

Submission Time
Task E - Count Median
User Nachia
Language C++ (GCC 9.2.1)
Score 500
Code Size 634 Byte
Status AC
Exec Time 70 ms
Memory 4664 KB

Compile Error

./Main.cpp: In member function ‘void Problem::Solve()’:
./Main.cpp:16:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   16 |   scanf("%u", &N);
      |   ~~~~~^~~~~~~~~~
./Main.cpp:17:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   17 |   rep(i, N) scanf("%u%u", A + i, B + i);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~

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 4536 KB
handmade03 AC 3 ms 4664 KB
handmade04 AC 3 ms 4628 KB
handmade05 AC 3 ms 4448 KB
handmade06 AC 3 ms 4492 KB
handmade07 AC 3 ms 4556 KB
handmade08 AC 2 ms 4540 KB
handmade09 AC 3 ms 4560 KB
handmade10 AC 3 ms 4612 KB
handmade11 AC 3 ms 4496 KB
handmade12 AC 44 ms 4556 KB
handmade13 AC 41 ms 4624 KB
handmade14 AC 69 ms 4512 KB
handmade15 AC 69 ms 4536 KB
handmade16 AC 54 ms 4608 KB
handmade17 AC 49 ms 4664 KB
random18 AC 22 ms 4580 KB
random19 AC 42 ms 4600 KB
random20 AC 69 ms 4540 KB
random21 AC 70 ms 4576 KB
random22 AC 2 ms 4568 KB
random23 AC 43 ms 4576 KB
random24 AC 36 ms 4564 KB
sample00 AC 3 ms 4608 KB
sample01 AC 3 ms 4544 KB