Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <iostream>
- #include <conio.h>
- #include <string>
- #include <math.h>
- #include <algorithm>
- #include <vector>
- #include <cmath>
- #include <set>
- using namespace std;
- int fact(long long n, long long i)
- {
- long long prom = 1;
- if (n != 0 && i!=0)
- {
- for (long long j = i; j <= n; j++)
- prom *= j;
- }
- return prom;
- }
- int main()
- {
- long long prom;
- long long sc[4]{ 0,0,0,0 };
- long long n;
- cin >> n;
- for (long long i = 1; i <= n; i++)
- {
- cin >> prom;
- sc[prom]++;
- }
- sort(sc + 1, sc + 1 + 3);
- if (n < 6)
- {
- prom = 1;
- for (long long i = 1; i <= 2; i++)
- prom = prom * fact(sc[i], 2);
- if (fact(n, sc[3] + 1) >= 6 * prom)
- cout << "Yes";
- else
- cout << "No";
- }
- else
- if (sc[3] == n)
- cout << "No";
- else
- cout << "Yes";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment