Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- #include <stdlib.h>
- #include <stack>
- #include <queue>
- #include <set>
- #include <map>
- #include <string>
- #include <algorithm>
- #include <iostream>
- using namespace std;
- class BI {
- vector<int> a;
- public:
- BI() {}
- void init(char *s) {
- int l = strlen(s);
- for (int i = l - 1; i >= 0; i--)
- a.push_back(s[i] - '0');
- }
- string toString() {
- string r = "";
- for (int i = a.size() - 1; i >= 0; i--)
- r.push_back('0' + a[i]);
- return r;
- }
- bool operator < (const BI &x) const {
- if (a.size() != x.a.size())
- return a.size() < x.a.size();
- for (int i = a.size() - 1; i >= 0; i--)
- if (a[i] != x.a[i])
- return a[i] < x.a[i];
- return 0;
- }
- BI operator + (const BI &x) const {
- BI r;
- int s = 0, o = 0;
- for (int i = 0; i < max(a.size(), x.a.size()); i++) {
- s = o;
- if (i < a.size())
- s += a[i];
- if (i < x.a.size())
- s += x.a[i];
- o = s / 10;
- r.a.push_back(s % 10);
- }
- if (o)
- r.a.push_back(o);
- return r;
- }
- } bi[1010];
- int n;
- char s[510];
- int main() {
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- scanf("%d\n", &n);
- for (int i = 0; i < n; i++) {
- scanf("%s\n", s);
- bi[i].init(s);
- }
- sort(&bi[0], &bi[n]);
- for (int i = 2; i < n; i++) {
- if ((bi[i - 2] < bi[i - 1] + bi[i]) &&
- (bi[i - 1] < bi[i - 2] + bi[i]) &&
- (bi[i] < bi[i - 2] + bi[i - 1])) {
- printf("%s %s %s", bi[i - 2].toString().c_str(), bi[i - 1].toString().c_str(), bi[i].toString().c_str());
- return 0;
- }
- }
- printf("0 0 0");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement