codeforce Amr and The Large Array
来源:互联网 发布:升级软件 图标 icon 编辑:程序博客网 时间:2024/05/17 06:31
好吧,我等没出息的男人只能没事刷刷水题
题意,给你一串数字,输出其钟出现最多的数的第一次出现的地方和最后一次出现的地方
输入的时候将每个数的头和尾标记一下然后简单的判断一下最多的那个数的头和尾就行了
#include<iostream>#include<algorithm>#include<cstring>#include<cmath>#include<vector>#include<cstdio>#include<map>using namespace std;int num[1000010];int tou[1001010];int wei[1001000];int main(){ int n,k,i; while(scanf("%d",&n)!=EOF) { k=-11; int a;int maxx=-222; memset(num,0,sizeof(num)); for(i=1;i<=n;i++) { scanf("%d",&a); k=max(k,a); if(num[a]==0) { tou[a]=i; } num[a]+=1; wei[a]=i; maxx=max(maxx,num[a]); } int da=44443333;int xuan; for(i=1;i<=k;i++) { if(num[i]==maxx) { if(wei[i]-tou[i]<da) { xuan=i; da=wei[i]-tou[i]; } else if(wei[i]-tou[i]==da) { if(tou[xuan]>tou[i]) xuan=i; } } } printf("%d %d\n",tou[xuan],wei[xuan]); } return 0;}
0 0
- codeforce Amr and The Large Array
- codeforce 558B Amr and The Large Array 思维题
- Amr and The Large Array
- Amr and The Large Array
- Amr and The Large Array
- codeforcesB. Amr and The Large Array
- B. Amr and The Large Array
- B-codeforces558B-Amr and The Large Array
- Codeforces 558B Amr and The Large Array(hash)
- CF 558B(Amr and The Large Array-计数)
- codeforces #312 B B. Amr and The Large Array(统计)
- Codeforces 558B Amr and The Large Array
- codeforces 558B Amr and The Large Array-yy
- CF 558B Amr and The Large Array
- 【36.86%】【codeforces 558B】Amr and The Large Array
- Codeforces 558B Amr and The Large Array 数组美丽值
- CF 558B Amr and The Large Array(暴力法)
- Codeforces Round #312 (Div. 2) B. Amr and The Large Array
- mysql ERROR 1045 (28000): Access denied for user解决方法
- 在线预览pdf
- 伊宁代办医院诊断证明
- MathType中如何编辑低阶导数
- 长沙代办医院诊断证明
- codeforce Amr and The Large Array
- 一切成功源于积累——20150812 欧美单日最大涨幅 超级强势涨 1900点 澳美反弹1000点
- 邵阳代办医院诊断证明
- MSYS2的源配置
- 岳阳代办医院诊断证明
- 黑马程序员——25,打印流,合并流,对象序列化,管道流,RandomAccessFile
- 北京代办医院诊断书
- 天津代办医院诊断书
- 上海代办医院诊断书