Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int data[110];
- bool bi = true, in = true, de = true;
- int main() {
- int n;
- scanf("%d", &n);
- for (int i = 0; i < n; ++i) {
- scanf("%d", &data[i]);
- }
- int bitonicPoint = -1;
- for (int i = 0; i < n - 2; ++i) {
- if ((data[i + 1] > data[i] && data[i + 2] < data[i + 1])) {
- bitonicPoint = i + 1;
- }
- }
- if (n > 1 && bitonicPoint != -1) {
- bool increase = false;
- if (data[0] > data[1]) increase = false;
- else if (data[0] < data[1]) increase = true;
- if (!increase) {
- for (int i = 0; i <= bitonicPoint - 1; ++i) {
- if (data[i] < data[i + 1]) {
- bi = false;
- break;
- }
- }
- for (int i = bitonicPoint; i < n - 1; ++i) {
- if (data[i] > data[i + 1]) {
- bi = false;
- break;
- }
- }
- }
- else if (increase) {
- for (int i = 0; i <= bitonicPoint - 1; ++i) {
- if (data[i] > data[i + 1]) {
- bi = false;
- break;
- }
- }
- for (int i = bitonicPoint; i < n - 1; ++i) {
- if (data[i] < data[i + 1]) {
- bi = false;
- break;
- }
- }
- }
- }
- else if (n == 1) bi = true;
- else bi = false;
- for (int i = 0; i < n - 1; ++i) {
- if (data[i] >= data[i + 1]) {
- in = false;
- break;
- }
- }
- for (int i = 0; i < n - 1; ++i) {
- if (data[i] <= data[i + 1]) {
- de = false;
- break;
- }
- }
- for (int i = 0; i < n - 1; ++i) {
- if (data[i] == data[i + 1]) {
- bi = false;
- in = false;
- de = false;
- break;
- }
- }
- if (bi || in || de) printf("Yes");
- else printf("No");
- }
Add Comment
Please, Sign In to add comment