Skip to content

Instantly share code, notes, and snippets.

@brickgao
Created September 11, 2012 17:32
Show Gist options
  • Save brickgao/3700086 to your computer and use it in GitHub Desktop.
Save brickgao/3700086 to your computer and use it in GitHub Desktop.
Codeforces Round #137 (Div. 2) D
//By Brickgao
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
int n, x;
int a[100010], b[100010];
bool cmp(int a, int b)
{
return a > b;
}
int main()
{
int i, ans, tail;
while(~scanf("%d%d", &n, &x))
{
for(i = 0; i < n; i++)
scanf("%d", &a[i]);
for(i = 0; i < n; i++)
scanf("%d", &b[i]);
sort(a, a + n, cmp);
sort(b, b + n, cmp);
ans = 0;
tail = n - 1;
for(i = 0; i < n ; i++)
{
while(a[i] + b[tail] < x && tail >= 0) tail --;
if(tail >= 0)
{
ans ++;
tail --;
}
}
printf("1 %d\n", ans);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment