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
",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
");
        else if (n == 0) printf("0.00000
"); else printf("0.50000
");
    }
    return 0;
}

  

原文地址:https://www.cnblogs.com/Accpted/p/11475014.html