Topcoder SRM646 DIV2 1000

题目大意:给你两个vector,一个代表队伍的得分,一个代表得分为这个得分的队伍的个数,假设每支队伍还有两次比赛没有进行,比赛的规则是赢一场得3分,输一场得0分,没有平的情况。已知这个队伍的目前得分让你求出来所有的球队打完最后一场,这个球队理论上的最好排名,注意可以和除了自己以外的任何一支队伍进行比赛,次数任意。

解题思路:显然排名高的话,这个球队这两次比赛一定得赢,所以主要分为3种情况:1,即使得分+6也不会超过的,这些球队即使全输也会在他们前面,所以我们让他们全赢,2,低于m的,这些球队即使赢了也就<= m+6,所以也没有影响,就让它们也赢,3,位于m+3< x <= m+6这些人赢一场就会超过m+6,先让大于m+6与<=m的去赢他们,然后剩下的之间相互赢每个人都只赢两场,就是对半分。再剩下的一定就会排在当前人的前面。

Problem Statement

  John and Brus are the managers of your football team. The team is taking part in a tournament. The tournament is almost over: each team still has exactly two matches to play (possibly both against the same opponent). Note that two different teams play in
each match.

There are no ties in this tournament. Each match is played until one of the two teams wins. The winner of a match gets 3 points, the loser gets 0 points.

You are given an int yourScore: the number of points your team has scored so far. You are also given two vector <int>s
scores and numberOfTeams that describe the other teams. For each valid i, there are
numberOfTeams[i] other teams that each have scored scores[i] points so far. Note that the total number of teams in the tournament is 1 + sum(numberOfTeams).

At the end of the tournament, teams will be ranked by the total number of points. Teams with the same number of points will be ranked according to their total score.

Given the above information, you are interested in the best possible (1-based) final rank of your team. Note that you do not know which matches are still to be played, so you assume the best possible combination of matches that is consistent with the given
information.

In other words, you want to find the smallest X such that there exists a valid set of future match results that causes your team to end in X-th place. Note that your team‘s score can be arbitrarily good, so you may always assume that your team is placed above
all other teams that have the same score as you.

Compute and return the X defined above.

Definition

 
Class: TheFootballDivTwo
Method: find
Parameters: int, vector <int>, vector <int>
Returns: int
Method signature: int find(int yourScore, vector <int> scores, vector <int> numberOfTeams)
(be sure your method is public)

Limits

 
Time limit (s): 2.000
Memory limit (MB): 256
Stack limit (MB): 256

Notes

- The current scores given in yourScore and scores do not necessarily correspond to a valid game history. In particular, they do not have to be divisible by 3.

Constraints

- yourScore will be between 0 and 100,000, inclusive.
- scores will contain between 1 and 47 elements, inclusive.
- scores and numberOfTeams will contain the same number of elements.
- Each element of scores will be between 0 and 100,000, inclusive.
- Each element of numberOfTeams will be between 1 and 100,000, inclusive.

Examples

0)  
 
4
{7}
{1}
Returns: 1
There are two teams in the tournament. They play two games against each other. If your team wins both games it will be on the top of the scoreboard with 10 points.
1)  
 
1
{7}
{2}
Returns: 2
There are three teams. Your team has 1 point and each of the other two teams has 7 points. With three teams, the remaining matches are determined uniquely: each pair of teams must play a single match against each other. The best possible final
result for your team is to place second with 7 points.
2)  
 
1
{7, 1}
{2, 1}
Returns: 1
There are four teams - two with 1 point each and two with 7 points each. If each 1-point team plays against each 7-point team and wins, each team will have 7 points in the end.
3)  
 
11
{5, 12, 17, 19, 99, 13, 15, 14}
{2, 4, 8, 2, 1, 3, 25, 3}
Returns: 18
#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#define eps 1e-10
///#define M 1000100
///#define LL __int64
#define LL long long
#define INF 0x7fffffff
#define PI 3.1415926535898
#define zero(x) ((fabs(x)<eps)?0:x)

using namespace std;

const int maxn = 2010;

int mp[maxn][maxn];

class TheFootballDivTwo
{
public:
    int find(int yourScore, vector <int> scores, vector <int> numberOfTeams)
    {
        int n = scores.size();
        int Min = 0;
        int Max = 0;
        int m = yourScore;
        int xp = 0;
        for(int i = 0; i < n; i++)
        {
            int x = scores[i];
            int y = numberOfTeams[i];
            if(x > m+6)
            {
                Min += y;
                xp += y;
            }
            if(x <= m) Min += y;
            if(m+4 <= x && x <= m+6) Max += y;
        }
        Max -= Min;
        Max -= 1;
        if(Max <= 0) return xp+1;
        Max += 1;
        Max /= 2;
        return xp+Max+1;
    }
};
int main()
{

    return 0;
}

时间: 2024-11-14 12:49:35

Topcoder SRM646 DIV2 1000的相关文章

TOPCODER SRM 686 div2 1000

// TOPCODER SRM 686 div2 1000 Problem Statement 给出一个至多长 100 的字符串,仅包含 ( 和 ),问其中有多少个不重复的,合法的括号子序列. 子序列可以不连续:合法即括号序列的合法:答案模 1,000,000,007. Examples "(())(" Returns: 2 Correct non-empty bracket subsequences are "()" and "(())". &

Topcoder SRM 648 Div2 1000

Problem 给一个长度为N的字符串S,S只含有'A'.'B'.'C'三种元素.给定一个K,要求返回字符串S,使得S中恰好有K对pair(i,j)满足 0=<i<j<N,且 S[i]<S[j].若不存在,则返回空串. Limits Time Limit(ms): 2000 Memory Limit(MB): 256 N: [3, 30] K: [0, N*(N-1)/2 ] Solution 设S中含有n1个'A',n2个'B',n3个'C',设num=n1*n2+n1*n3+n

SRM627 Div2 1000 DP

[题意]:给出一个数列,可以进行的操作为最多能取K个互相不重叠的区间并将其反转,问经过操作以后,用冒号排序法排序数组所能达到的数的交 换次数的最小值.例如:一个数列{7,2,2,13,5,5,2}最多可以取2个互相不重叠的区间,那么有[0,2],[3,6],反转后的数组为{2,2,7,2,5,5,13},用冒号排 序法排序时所需要的交换次数为3.[知识点]:DP[题解1]:记忆化搜索DP(递归DP)虽然我知道记忆化搜索这东西本身,但因为智商拙计经常用不上去,我觉得自己真的对编码本身还有待提高,下

topcoder SRM628 div2 500(转)

Problem Statement      We have three types of brackets: "()", "[]", and "{}". We are now interested in some special strings. A string is special if all the following conditions hold: Each character of the string is one of the

Topcoder Srm 673 Div2 1000 BearPermutations2

\(>Topcoder \space Srm \space 673 \space Div2 \space 1000 \space BearPermutations2<\) 题目大意 : 对于一个长度为 \(n\) 的排列,定义其的贡献为对其建笛卡尔树,树上有两个儿子的节点其左右儿子在原排列中的距离之和,给出 \(n, Mod\),求所有长度为 \(n\) 的排列的贡献之和对 \(Mod\) 取模的值 \(1 \leq n \leq 100\) 解题思路 : 考虑一个最暴力的 \(dp\) ,设

Topcoder SRM 654 Div2 1000

Problem 给一个长度为N(N∈[1,2000])的数列An(An∈[?100,100]),设ans=A1?A2?...?An,下面进行M(M∈[1,2000])次操作,每次将A的p[i]的值修改为v[i],即A[p[i]]=v[i],每次只允许加入最多2个括号进入ans等式,问ans的最大值可以是多少? Solution dp.. 设dp[i][j]表示从 1 到 i-1 已经有 j 个括弧时候的最大值,j=0时表示没有括弧,j=1时表示(这样子,j=2时表示(( 这个样子,j=3时表示(

Topcoder SRM632 DIV2 解题报告

250:乱搞 解题代码: 1 // BEGIN CUT HERE 2 /* 3 4 */ 5 // END CUT HERE 6 #line 7 "RunningAroundPark.cpp" 7 #include <cstdlib> 8 #include <cctype> 9 #include <cstring> 10 #include <cstdio> 11 #include <cmath> 12 #include <

SRM 628 DIV2 1000 CandleTimerEasy 状态压缩+DFS

题意:给你一个树型蜡烛,你可以从1个或多个叶子开始点蜡烛,问你能使蜡烛烧完以后能得到时间的个数. 解题思路:状态压缩枚举DFS, 解题代码: 1 // BEGIN CUT HERE 2 /* 3 4 */ 5 // END CUT HERE 6 #line 7 "CandleTimerEasy.cpp" 7 #include <cstdlib> 8 #include <cctype> 9 #include <cstring> 10 #include

topcoder 649 DIV2

8 A:模拟 9:B:终于看懂题目... 题意:最多分解K次 每分钟一个数可以分解成两个数 或者-1: 关键字:DP,记忆花搜索. DP[I][J]=min(dp[i][j],1+max(dp[ii][jj],dp[i-ii][j-jj-1]); 1 #include<iostream> 2 #include <string>  3 #include <vector>  4 #include<cmath>  5 #include <string.h&g