Topcoder SRM646 DIV2 1000

Source: Internet
Author: User

The main topic: give you two vector, a representative team score, a representative score for this score of the number of teams, assuming that each team has two times the game is not carried out, the rules of the game is to win a 3 points, lose a 0 points, no flat situation. It is known that the team's current score allows you to find out that all teams play the last game, the team's best ranked in theory, and be able to play against any team other than yourself.

Problem-solving ideas: Clearly ranked high, the team will have to win this two times, so the main divided into 3 cases: 1, even if the score +6 will not exceed, these teams even if all lose will be in front of them, so we let them all win, 2, lower than m, these teams even win the <= m+ 6, so there is no impact, let them also win, 3, is located in m+3< x <= m+6 These people win a game will be more than m+6, first let more than M+6 and <=m to win them, and then the rest of each other win each other only win two, is half points. The rest must be in front of the current person.

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 have exactly the matches to play (possibly both against the same opponent). Note that the different teams play in each match.

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

You is given an intYourscore: The number of points your team have scored so far. You is also given the vector <int>sscoresandNumberofteamsThat's describe the other teams. For each valid I, there isNumberofteams[I] Other teams, each has scoredscores[I] points so far. Note The total number of teams in the tournament is 1 + sum (Numberofteams).

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

Given The above information, you is interested in the best possible (1-based) final rank of your team. Note that you don't know which matches is still to being played, so you assume the best possible combination of matches tha T 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 this causes you R team to end in X-th place. Note that your team's score can be arbitrarily good, so if always assume that your team are placed above all other teas Ms that has 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 was public)
Limits
Time limit (s): 2.000
Memory Limit (MB): 256
Stack Limit (MB): 256
Notes
- The current scores given in Yourscore and scores does not necessarily correspond to a valid game history. In particular, they does not have the to is divisible by 3.
Constraints
- Yourscore 'll be between 0 and 100,000, inclusive.
- scores would contain between 1 and elements, inclusive.
- scores and Numberofteams would contain the same number of elements.
- Each element of scores would be between 0 and 100,000, inclusive.
- Each element of Numberofteams would be between 1 and 100,000, inclusive.
Examples
0)
4
{7}
{1}
Returns:1
There is teams in the tournament. They play against each of the other. If your team wins both games it is on the top of the scoreboard with the points.
1)
1
{7}
{2}
Returns:2
There is three teams. Your team have 1 point and each of the other teams have 7 points. With three teams, the remaining matches is determined Uniquely:each pair of teams must play a single match against each Other. The best possible final result for your team was to place second with 7 points.
2)
1
{7, 1}
{2, 1}
Returns:1
There is four teams-two with 1 point each and both with a 7 points each. If each 1-point team plays against each 7-point team and wins, each team'll has 7 points in the end.
3)
 
 one 
 {5, +, +, +---) 
 {2, 4, 8, 2, 1, 3,, 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> SCO        Res, 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;}


Topcoder SRM646 DIV2 1000

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.