Watching TV Gym101498A
来源:互联网 发布:阿里云服务器优点 编辑:程序博客网 时间:2024/05/17 23:32
一道水题。。。强迫症,既然做到了,还是想发个博。。。
**题意**Ahmed 的爸爸只允许他看相同频率的节目,一个频率可能接受到几个节目的信号。
思路:记下一个频率出现了多少次,然后输出出现次数最多的频率(若有多个频率出现次数最多且相同则输出其中最小的频率)
代码:
#include<cstdio>#include<cstring>#include<cstdlib>#include<stack>#include<queue>#include<utility>#include<vector>#include<cmath>#include<set>#include<map>#include<iostream>#include<algorithm>using namespace std;typedef long long LL;vector<int> F;set<int> chl;int hs[100000];int main(){ //freopen("in.txt", "r", stdin); int T; scanf("%d", &T); while(T--){ F.clear(); chl.clear(); memset(hs, 0, sizeof(hs)); int N; scanf("%d", &N); while(N--){ char name[55]; int f; scanf("%s%d", name, &f); hs[f]++; if(chl.count(f) == 0) {F.push_back(f); chl.insert(f);} } int ans = F[0], anscnt = hs[F[0]]; for(int i=0; i<F.size(); i++){ if(anscnt < hs[F[i]]){ anscnt = hs[F[i]]; ans = F[i]; } else if(anscnt == hs[F[i]]){ ans = min(ans, F[i]); } } printf("%d\n", ans); } return 0;}
阅读全文
0 0
- Watching TV Gym101498A
- 训练3+ A-Watching TV
- 看美剧《疑犯追踪》,学地道美语 Learn idiomatic American English by watching Tv series Person of Interest
- people watching
- TV
- TV
- Debugging by Watching -- strace
- 6656 Watching the Kangaroo
- codeforce499A - Watching a movie
- A. Watching a movie
- A. Watching a movie
- Watching the Kangaroo
- Watching a movie CodeForces
- uva 10339 - Watching Watches(数论)
- Codeforces Problem499A - Watching a movie
- UVa 10339 - Watching Watches (数学)
- 创维酷开tv
- linux & TV
- 侧拉SlidingMenu
- jmeter 前置处理器提取用户cookie信息 比如jsessionid
- 文件的权限和访问控制列表(ACL)
- 硬链接和软连接
- 短信验证的实现
- Watching TV Gym101498A
- C内存简析
- 今天给大家讲一些JS的东西,同时也是我们日常看到的APP当中很常见的一个模块,拖拽标题
- Dimens适配与布局适配
- 短信验证
- recycleview+okhttp请求数据
- 线性表的链式表示和实现
- PullToRefresh添加轮播图为头布局
- 链表题_1