Kattis-Black Friday
Posted 做一个AC梦
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Kattis-Black Friday相关的知识,希望对你有一定的参考价值。
题目链接
题目所述基本内容
Black Friday is the Friday following Thanksgiving Day in the United States (the fourth Thursday of November). Since the early 2000s, it has been regarded as the beginning of the Christmas shopping season in the US, and most major retailers open very early and offer promotional sales. (Source: Wikipedia)
Black friday by Powhusku
You work in the IT support division of an electronics store. This year, in an attempt to prevent overcrowding, the management has decided to limit the number of people entering the store. They divide the people at the entrance into groups of size n and process them as follows: all n participants roll a die, and report the outcomes a1,a2,…,an. To prevent cheating, instead of selecting the one with the highest outcome, the rule is to select the participant with the highest unique outcome. Everybody not selected has to move to the back of the queue. If there is no winner, the experiment is repeated.
For example, if there are three players and the outcomes are 6, 6 and 5, then the third player wins, because the first and second player lose even though their outcomes are higher, since they both have the same outcome. If instead the third player also rolls 6, then nobody wins.
They asked you to write a program for selecting the winner.
输入输出样例
Input
The first line of the input contains one integer n, 1≤n≤100, the group size. The second line contains a integers a1,a2,…,an (1≤ai≤6 for all 1≤i≤n): the outcome of each participant’s die roll.
Output
Output the index of the participant that has the highest unique outcome, or “none” (without the quotes) if nobody has a unique outcome.
Sample Input 1 | Sample Output 1 |
---|---|
8
1 1 1 5 3 4 6 6
| 4
|
Sample Input 2 | Sample Output 2 |
---|---|
3
4 4 4
| none
|
METADATA
CPU Time limit | 1 second |
Memory limit | 1024 MB |
Difficulty | 2.3 |
Show | Show |
Authors | Ulf Lundström and Jan Elffers |
Source | KTH Challenge 2015 |
代码
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
bool GreaterSort(int a, int b)
return (a > b);
int main()
map<int, int>match;
vector<int>p;
vector<int>q;
int temp = 0;
int num = 0;
cin >> num;
for (int i = 0; i < num; i++)
cin >> temp;
p.push_back(temp);
q.push_back(temp);
match[temp]++;
sort(p.begin(), p.end(), GreaterSort);
for (int i = 0; i < num; i++)
if (match[p[i]] == 1)
for (int j = 0; j < num; j++)
if (q[j] == p[i])
cout << j+1 << endl;
return 0;
cout << "none" << endl;
return 0;
结束语
好兄弟好兄弟,留下你的关注和点赞,666走一波!!!!!
以上是关于Kattis-Black Friday的主要内容,如果未能解决你的问题,请参考以下文章