标签:
| Time Limit: 1000MS | Memory Limit: 65536KB | 64bit IO Format: %I64d & %I64u |
Description
Input
Output
Sample Input
| input | output |
|---|---|
4 4 1 2 3 |
2 |
3 1 1 1 |
3 |
比赛时是队友写出来的,思路就是对每个人求满足其位置需求的排列第一个演讲的是谁,累加后“得票”最多的既为第一个演讲的人。
有个大神题解写的很明白,贴个链接
http://blog.csdn.net/pegasuswang_/article/details/10414563
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<utility>
#define inf 0x3f3f3f3f
#define eps 1e-6
int a[100010];
int cnt[100010];
using namespace std;
int main()
{
int n;
while(cin>>n)
{
for(int i=0;i<n;i++)
{
scanf("%d",a+i);
}
memset(cnt,0,sizeof(cnt));
for(int i=0;i<n;i++)
{
cnt[(i+n+1-a[i])%n]++;
}
int max=0;
int pos;
for(int i=0;i<n;i++)
{
if(cnt[i]>max)
{
max=cnt[i];
pos=i+1;
}
}
cout<<pos<<endl;
}
return 0;
}
URAL - 1794 Masterpieces of World Architecture(“投票法”)
标签:
原文地址:http://blog.csdn.net/qq_18738333/article/details/45161105