您的位置:首页 > 其它

Sicily 1641 Binary Searchable

2014-11-21 22:56 253 查看
水题,如果一个数比左面的都大,比右面的都小就是Binary Researchable

// Problem#: 1641
// Submission#: 3247168
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/ // All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include<iostream>
using namespace std;
int main() {
int n;
while (cin >> n) {
int a[105];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int count = 0;
bool left, dext;
for (int i = 0; i < n; i++) {
left = dext = true;
for (int j = i + 1; j < n; j++) {
if (a[i] > a[j]) {
dext = false;
break;
}
}
for (int j = i - 1; j >= 0; j--) {
if (a[i] < a[j]) {
left = false;
break;
}
}
if (left && dext) {
count++;
}
}
cout << count << endl;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: