码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-09-06 15:54:19      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:==   include   sort   less   const   main   http   pre   name   

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;
}

  

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

标签:==   include   sort   less   const   main   http   pre   name   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!