Skip to content

Commit

Permalink
Accepted
Browse files Browse the repository at this point in the history
  • Loading branch information
volzkzg committed Jul 28, 2013
1 parent 7184a4d commit 4d56592
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions 429.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;

int a[10],n;

int main()
{
ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; ++i) cin >> a[i];
if (n == 1) {
cout << "FEDOR" << endl;
} else if (n == 2) {
if (a[1] != a[2]) cout << "FEDOR" << endl;
else cout << "SERGEY" << endl;
} else if (n == 3) {
if (a[1] == a[3] && a[2] != a[1]) cout << "SERGEY" << endl;
else cout << "FEDOR" << endl;
} else if (n == 4) {
if (a[1] > a[4]) {
swap(a[1],a[4]);
swap(a[2],a[3]);
}
if (a[1] == a[4]) {
if (a[2] > a[1] && a[3] > a[1]) cout << "SERGEY" << endl;
else if (a[2] == a[1] && a[3] == a[1]) cout << "SERGEY" << endl;
else if (a[2] < a[1] && a[3] < a[1]) cout << "SERGEY" << endl;
else cout << "FEDOR" << endl;
} else if (a[1] == (a[4] - 1)) {
if (a[2] <= a[1] && a[3] >= a[4])
cout << "SERGEY" << endl;
else
cout << "FEDOR" << endl;
} else cout << "FEDOR" << endl;
} else if (n == 5) {
if (a[1] > a[5]) {
swap(a[1],a[5]);
swap(a[2],a[4]);
}
if (a[1] == a[5]) {
if (a[2] > a[4]) {
swap(a[2],a[4]);
}
if (a[3] < a[1]) {
if (a[2] < a[1] && a[4] < a[1]) cout << "SERGEY" << endl;
else if (a[2] >= a[1] && a[4] >= a[1]) cout << "SERGEY" << endl;
else cout << "FEDOR" << endl;
} else if (a[3] == a[1]) {
if (a[2] < a[1] && a[4] <= a[1]) cout << "SERGEY" << endl;
else if (a[2] >= a[1] && a[4] > a[1]) cout << "SERGEY" << endl;
else cout << "FEDOR" << endl;
} else if (a[3] > a[1]) {
if (a[2] <= a[1] && a[4] <= a[1]) cout << "SERGEY" << endl;
else if (a[2] > a[1] && a[4] > a[1]) cout << "SERGEY" << endl;
else cout << "FEDOR" << endl;
}
} else if (a[1] == (a[5] - 1)) {
if (a[2] < a[1]) {
if (a[3] <= a[1] && a[4] >= a[5]) cout << "SERGEY" << endl;
else if (a[3] > a[1] && a[4] > a[5]) cout << "SERGEY" << endl;
else cout << "FEDOR" << endl;
} else if (a[2] == a[1]) {
if (a[3] > a[1] && a[4] > a[5]) cout << "SERGEY" << endl;
else cout << "FEDOR" << endl;
} else cout << "FEDOR" << endl;
} else cout << "FEDOR" << endl;
}
return 0;
}

0 comments on commit 4d56592

Please sign in to comment.