UVA10474 Where is the Marble?
来源:互联网 发布:微课录制软件 编辑:程序博客网 时间:2024/04/29 16:42
给你一串序列,问你某个数在这个序列中是第几大,这个数也可能不存在
注:某些OJ可能会提示PE
#include<stdio.h>#include<algorithm>#include<iostream>#include<string.h>using namespace std;int con[100000];/*int minsearch(int v,int y){int m, x = 0;while (x < y){m = x + (y - x) / 2;if (con[m] == v)return m;else if (con[m]>v)y = m;else x = m + 1;}return -1;}*/int sbsearch(int v){int num=0;if (con[v] == 0)return -1;for (int i = 1; i < v; i++){if (con[i] == 0)continue;else num += con[i];}return num;}int main(){int n, m, t = 1;;while (scanf_s("%d%d", &n, &m) && n&&m){memset(con, 0, sizeof(con));int a;for (int i = 0; i < n; i++){scanf_s("%d", &a);con[a]++;}//sort(con, con + n);int v;printf("CASE# %d:\n", t++);//for (int i = 1; i <= n; i++)//cout << i<<" "<<con[i] << endl;for (int i = 0; i < m; i++){int v;scanf_s("%d", &v);if (sbsearch(v)==-1)cout << v << " not found" << endl;elsecout << v << " found at " << sbsearch(v)+1 << endl;}}return 0;}
0 0
- uva10474 - Where is the Marble?
- UVa10474 Where is the Marble?
- UVA10474-Where is the Marble?
- UVA10474 Where is the Marble?
- uva10474 - Where is the Marble?
- uva10474 Where is the Marble?
- uva10474 - Where is the Marble?
- UVA10474 Where is the Marble?
- UVA10474 Where is the Marble?
- UVA10474 Where is the Marble?
- UVa10474-Where is the Marble?
- uva10474大理石在哪儿where is the marble?
- UVA10474 where is the Marble? STL初步
- Uva10474——Where is the Marble?
- 5-1 UVa10474 Where is the Marble?
- UVA10474-5.1-Where is the Marble?
- UVA10474 Where is the Marble?(二分查找,STL-lower_bound)
- Where is the Marble
- hadoop 轻松时刻 hdfs漫画
- iOS下KVO使用过程中的陷阱
- 漫谈程序员(十八)windows中的命令subst
- 从gpu到chromium compositor(cc)详解android4.4 webview chromium v37硬件绘制流程
- perl编程总结
- UVA10474 Where is the Marble?
- 选项ui
- BZOJ1031: [JSOI2007]字符加密Cipher
- ViewPager 详解(一)---基本入门
- kafka入门:简介、使用场景、设计原理、主要配置及集群搭建(转)
- perl基础入门
- 【USACO】坏掉的项链
- c++ 静态成员变量
- perl之正则表达式