Skip to content

Instantly share code, notes, and snippets.

@jamby77
Created November 7, 2017 18:56
Show Gist options
  • Save jamby77/853717060d7fc88a1e31c430aa3c6296 to your computer and use it in GitHub Desktop.
Save jamby77/853717060d7fc88a1e31c430aa3c6296 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
int N, t, a,b,c;
int Nmax = 1000000; // po uslovie N ne moje da e poveche ot tova chislo
int tMax = 10000; // vs chislo sled N ne moje da e poveche ot tova
cin >> N;
cout << "N is: " << N << "\n";
if (N > Nmax) {
cout << "N is too big";
return 1;
}
for (int i = 0; i < N; i++) {
cin >> t;
cout << "t is: " << t << ", i is: " << i << "\n";
if (t > tMax) {
cout << "too big number passed, max number alloed is " << tMax;
}
if (i == 0) {
a = t;
cout << "a is: " << a << ", i is: " << i <<"\n";
continue;
}
if(i == 1) {
b = t;
cout << "b is: " << b <<", i is: " << i << "\n";
continue;
}
if (i == 2) {
c = t;
} else {
a = b;
b = c;
c = t;
}
cout << "a is: " << a << ", i is: " << i <<"\n";
cout << "b is: " << b << ", i is: " << i <<"\n";
cout << "c is: " << c << ", i is: " << i <<"\n";
if ((a >= b && c >= b) || (b > a && b > c)) {
continue;
} else {
cout << "No\n";
return 0;
}
}
cout << "Yes\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment