Nordic Collegiate Programming Contest 2017 题解

前几天打了一场外国人的比赛,感觉那边的题目质量还是很好的,区分度很鲜明,题目没有国内的难,坑点比较少,比较注重思维,基础算法。


B题:

Best Relay Team

/problems/bestrelayteam/file/statement/en/img-0001.jpg
Picture by Fernando Frazão/Agência Brasil, cc by
You are the coach of the national athletics team and need to select which sprinters should represent your country in the  4×100 4×100 m relay in the upcoming championships.

As the name of the event implies, such a sprint relay consist of  4 4legs,  100 100 meters each. One would think that the best team would simply consist of the  4 4 fastest  100 100 m runners in the nation, but there is an important detail to take into account: flying start. In the  2 2nd,  3 3rd and  4 4th leg, the runner is already running when the baton is handed over. This means that some runners – those that have a slow acceleration phase – can perform relatively better in a relay if they are on the  2 2nd,  3 3rd or  4 4th leg.

You have a pool of runners to choose from. Given how fast each runner in the pool is, decide which four runners should represent your national team and which leg they should run. You are given two times for each runner – the time the runner would run the  1 1st leg, and the time the runner would run any of the other legs. A runner in a team can only run one leg.

Input

The first line of input contains an integer  n n, the number of runners to choose from ( 4n500 4≤n≤500). Then follow  n n lines describing the runners. The  i i’th of these lines contains the name of the  i i’th runner, the time  ai ai for the runner to run the  1 1st leg, and the time  bi bi for the runner to run any of the other legs ( 8biai<20 8≤bi≤ai<20). The names consist of between  2 2 and  20 20 (inclusive) uppercase letters ‘A’-‘Z’, and no two runners have the same name. The times are given in seconds with exactly two digits after the decimal point.

Output

First, output a line containing the time of the best team, accurate to an absolute or relative error of at most  109 10−9. Then output four lines containing the names of the runners in that team. The first of these lines should contain the runner you have picked for the  1 1st leg, the second line the runner you have picked for the  2 2nd leg, and so on. Any solution that results in the fastest team is acceptable.

Sample Input 1 Sample Output 1
6
ASHMEADE 9.90 8.85
BLAKE 9.69 8.72
BOLT 9.58 8.43
CARTER 9.78 8.93
FRATER 9.88 8.92
POWELL 9.72 8.61
35.54
CARTER
BOLT
POWELL
BLAKE
Sample Input 2 Sample Output 2
9
AUSTRIN 15.60 14.92
DRANGE 15.14 14.19
DREGI 15.00 14.99
LAAKSONEN 16.39 14.97
LUNDSTROM 15.83 15.35
MARDELL 13.36 13.20
POLACEK 13.05 12.55
SANNEMO 15.23 14.74
SODERMAN 13.99 12.57
52.670000
MARDELL
POLACEK
SODERMAN
DRANGE
这个题是签到题,比较简单,枚举第一个人,后面三个人取最快的三个人就行

#include <bits/stdc++.h>
using namespace std;
const int maxn = 500 + 10;
int n;
double eps = 0.0000000001;
struct node{
    string name;
    double speed1, speed2;
    bool operator <(const node &res) const{
        return speed2 < res.speed2;
    }
}Node[maxn];
vector<node> g;
int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
        cin>>Node[i].name>>Node[i].speed1>>Node[i].speed2;
    }
    double Min = 1000000000000.0;
    string s1, s2, s3, s4;
    for(int i = 1; i <= n; i++)
    {
        g.clear();
        double sum = Node[i].speed1;
        for(int j = 1; j <= n; j++)
        {
            if(j != i) g.push_back(Node[j]);
        }
        sort(g.begin(), g.end());
        for(int j = 0; j <= 2; j++)
        {
            sum += g[j].speed2;
        }
        if(sum - Min < eps)
        {
            Min = sum;
            s1 = Node[i].name;
            s2 = g[0].name;
            s3 = g[1].name;
            s4 = g[2].name;
        }

    }
    printf("%.2lf\n", Min);
    cout<<s1<<endl<<s2<<endl<<s3<<endl<<s4<<endl;
    return 0;
}

D题:

Distinctive Character

/problems/distinctivecharacter/file/statement/en/img-0001.jpg
Picture by Fairytalemaker on Pixabay
Tira would like to join a multiplayer game with  n n other players. Each player has a character with some features. There are a total of  k k features, and each character has some subset of them.

The similarity between two characters  A A and  B B is calculated as follows: for each feature  f f, if both  A A and  B B have feature 

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值