题意:
给你两组分数,让你在每一组中选择一个相加,在分数总和大于等于x的
情况下,选手的最好最坏名次。这个真是xjb贪心,完全不知道为什么回
过。我是这么搞得:
最好的名次是第一毋庸置疑。
然后,两组分数进行排序,一个升序,一个降序。之后进行匹配,尽量
将第一组最小的和第二组最大的结合来算第一次最坏名次,这是一个答
案。然后将两组分数翻转,再次进行一次同样的匹配,两次答案比较即
可。我也不知道为啥这样就对了,2333333
代码:
//
// Created by CQU_CST_WuErli
// Copyright (c) 2015 CQU_CST_WuErli. All rights reserved.
//
// #include<bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#define CLR(x) memset(x,0,sizeof(x))
#define OFF(x) memset(x,-1,sizeof(x))
#define MEM(x,a) memset((x),(a),sizeof(x))
#define For_UVa if (kase!=1) cout << endl
#define BUG cout << "I am here" << endl
#define lookln(x) cout << #x << "=" << x << endl
#define SI(a) scanf("%d",&a)
#define SII(a,b) scanf("%d%d",&a,&b)
#define SIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define rep(flag,start,end) for(int flag=start;flag<=end;flag++)
#define Rep(flag,start,end) for(int flag=start;flag>=end;flag--)
#define Lson l,mid,rt<<1
#define Rson mid+1,r,rt<<1|1
#define Root 1,n,1
#define BigInteger bign
template <typename T> T gcd(const T& a,const T& b) {return b==0?a:gcd(b,a%b);}
const int MAX_L=2005;// For BigInteger
const int INF_INT=0x3f3f3f3f;
const long long INF_LL=0x7fffffff;
const int MOD=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
typedef long long ll;
using namespace std;
int n,x;
int a[100010],b[100010];
bool cmp(int x,int y) {
return x>y;
}
int main(){
#ifdef LOCAL
freopen("C:\\Users\\john\\Desktop\\in.txt","r",stdin);
// freopen("C:\\Users\\john\\Desktop\\out.txt","w",stdout);
#endif
while (SII(n,x)==2) {
rep(i,1,n) SI(a[i]);
rep(i,1,n) SI(b[i]);
sort(a+1,a+1+n);
sort(b+1,b+1+n,cmp);
int ans=1;
int cnt=0;
int l=1,r=1;
while (l<=n && r<=n) {
if (a[l]+b[r]>=x) {
cnt++;
l++,r++;
}
else l++;
}
ans=max(ans,cnt);
reverse(a+1,a+1+n);
reverse(b+1,b+1+n);
cnt=0;
l=r=1;
while (l<=n && r<=n) {
if (b[l]+a[r]>=x) {
cnt++;
l++,r++;
}
else l++;
}
ans=max(ans,cnt);
cout << 1 << ' ' << ans << endl;
}
return 0;
}