hdu 5364

#include <iostream>
#include <stdio.h>
#include<math.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int main()
{
  int n,s[1005];
  int u,flag,min;
  while(cin>>n)
  {
    min=u=0;
    memset(s,0,1005);
    for(int i=1;i<=n;i++)
    cin>>s[i];
    for(int k=1;k<=n;k++)
    {
      flag=1;
      for(int j=k+1;j<=n+1;j++)
      {
        if(s[k] == s[j])
        {
          flag++;
          if(flag>min)
          {
            u=k;
            min=flag;
          }
        }
      }

    }
    if(u!=0 && min>(n-min))
      cout<<s[u]<<endl;
    else
      cout<<"-1"<<endl;
  }
  return 0;
}

时间: 2024-07-29 23:12:30

hdu 5364的相关文章

HDU 5364 5366

Distribution money Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 511    Accepted Submission(s): 291 Problem Description AFA want to distribution her money to somebody.She divide her money int

HDU 5364 Distribution money

Problem Description AFA want to distribution her money to somebody.She divide her money into n same parts.One who want to get the money can get more than one part.But if one man's money is more than the sum of all others'.He shoule be punished.Each o

hdu 5364 (bc#50 1001) Distribution money

Distribution money Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 276    Accepted Submission(s): 163 Problem Description AFA want to distribution her money to somebody.She divide her money into

HDU 5364-Distribution money(水题)

题目地址:HDU 5364 中文题意: 问题描述 地主小花难得当一回好人,这次她准备给长工们发津贴.有些长工会偷偷地在领完津贴后又排回队伍里去领津贴.不过小花对此表示无所谓,因为她发的是固定数额的津贴.但是如果有人领到的津贴超过其他所有人的总和的话,小花为了显示自己的公正,会去惩罚他.现已知每个来领津贴的人会登记下自己的工号. 输入描述 输入有多组数据,每组第一行为一个n(1 < = n < = 1000),表示有多少津贴被领,第二行n个数字a1,a2-an,表示n个来领津贴的人的工号(0 &

BestCoder Round #50 (div.1) 1001 Distribution money (HDU OJ 5364)

题目:Click here 题意:bestcoder上面有中文题目 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 #include <cmath> 6 #include <string> 7 #include <climits> 8 #include <vector> 9 #incl

HDU 6203 ping ping ping [LCA,贪心,DFS序,BIT(树状数组)]

题目链接:[http://acm.hdu.edu.cn/showproblem.php?pid=6203] 题意 :给出一棵树,如果(a,b)路径上有坏点,那么(a,b)之间不联通,给出一些不联通的点对,然后判断最少有多少个坏点. 题解 :求每个点对的LCA,然后根据LCA的深度排序.从LCA最深的点对开始,如果a或者b点已经有点被标记了,那么continue,否者标记(a,b)LCA的子树每个顶点加1. #include<Bits/stdc++.h> using namespace std;

HDU 5542 The Battle of Chibi dp+树状数组

题目:http://acm.hdu.edu.cn/showproblem.php?pid=5542 题意:给你n个数,求其中上升子序列长度为m的个数 可以考虑用dp[i][j]表示以a[i]结尾的长度为j的上升子序列有多少 裸的dp是o(n2m) 所以需要优化 我们可以发现dp的第3维是找比它小的数,那么就可以用树状数组来找 这样就可以降低复杂度 #include<iostream> #include<cstdio> #include<cstring> #include

hdu 1207 汉诺塔II (DP+递推)

汉诺塔II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4529    Accepted Submission(s): 2231 Problem Description 经典的汉诺塔问题经常作为一个递归的经典例题存在.可能有人并不知道汉诺塔问题的典故.汉诺塔来源于印度传说的一个故事,上帝创造世界时作了三根金刚石柱子,在一根柱子上从下往

[hdu 2102]bfs+注意INF

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2102 感觉这个题非常水,结果一直WA,最后发现居然是0x3f3f3f3f不够大导致的--把INF改成INF+INF就过了. #include<bits/stdc++.h> using namespace std; bool vis[2][15][15]; char s[2][15][15]; const int INF=0x3f3f3f3f; const int fx[]={0,0,1,-1};