4882.多段线性函数

input:linear.in output:linear.out

Time Limits: 1000 ms Memory Limits: 524288 KB

Description

img

Input

img

Output

输出文件名为linear.out。
输出一行两个自然数,用空格隔开,依次为L和R。

Sample Input

1
2
3
4
5
6
5
1 3
2 3
3 5
5 5
6 7

Sample Output

1
3 5

Data Constraint

img

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
const int MAXN = 1e5 + 5;
int a[2 * MAXN], n, cnt;
int main() {
freopen ("linear.in", "r", stdin);
freopen ("linear.out", "w", stdout);
scanf ("%d", &n);
for (int i = 1; i <= n; i++) {
int l, r;
scanf ("%d%d", &l, &r);
a[++cnt] = l;
a[++cnt] = r;
}
sort (a + 1, a + cnt + 1);
printf ("%d %d\n", a[n], a[n + 1]);
fclose (stdin);
fclose (stdout);
return 0;
}
暗影 微信

微信