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; } }
相关文章推荐
- [topcoder]BinarySearchable
- sicily Binary Search
- sicily inorder traversal for Binary Tree[递归和非递归]
- sicily 1509. Rails
- LEETCODE: Binary Tree Level Order Traversal II
- LeetCode Binary Tree Level Order Traversal II
- mysql中binary相加的问题
- 算法系列——Binary Tree Level Order Traversal II
- sicily.1813 M进制数问题
- LEETCODE: Binary Tree Maximum Path Sum
- leetcode: (226) Invert Binary Tree
- Invert Binary Tree
- Validate Binary Search Tree
- 在Web页内显示Binary(位图)的组件
- Validate Binary Search Tree
- Leetcode---Binary Tree Maximum Path Sum
- [Leetcode] Binary Tree Right Side View
- lintcode minimum-depth-of-binary-tree 二叉树最小深度
- 【基础知识】 binary search tree
- Introduction to C/C++ Binary Library