2017年ICPC中国大陆区域赛真题(下)

2017年ICPC中国大陆区域赛真题(下)

A - Lovers

#include <bits/stdc++.h>
using namespace std;

const int maxn=2e5+10;
int n,k,a[maxn],b[maxn],ans;
int main() {
    int _;
    scanf("%d", &_);
    while (_--) {
        scanf("%d%d", &n, &k);

        for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
        sort(a + 1, a + n + 1, greater<int>());
        for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
        sort(b + 1, b + n + 1, less<int>());

        int x = 1, y = 1;
        ans=0;
        while (x <= n && y <= n) {
            if (a[x] + b[y] >= k) {
                ans++;
                x++;
                y++;
            }else y++;
        }
        printf("%d\n",ans);
    }
    return 0;
}

B - God of Gamblers 

#include <bits/stdc++.h>
using namespace std;

const int maxn=2e5+10;

int n,m;

int main() {
    while (~scanf("%d%d", &n, &m)) {
        if (m == 0)
            printf("1.00000\n");
        else if (n == 0) printf("0.00000\n"); else printf("0.50000\n");
    }
    return 0;
}

  

posted @ 2019-09-06 15:20  Snow_in_winer  阅读(293)  评论(0)    收藏  举报