题目大意
给你 n 本书,每本书有五种属性值。让你选出两本书然后组成一本新的数,新书的每个属性值为原来两本书中最大的哪一个。问你挑选哪两本书可以使得新书的最小属性值最大;如果有多组数据满足要求输出下标最小的那组数据
数据范围1e5;
解题思路
一般涉及最大值最小的题都和二分有关。二分枚举最小值最大可以是多少。
代码
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
int a[N][5], p, q, n;
int b[N], c[50];
bool check(int x) {
memset(b, 0, sizeof(b));
memset(c, 0, sizeof(c));
for(int i = 0; i < n; i++) {
for(int j = 0; j < 5