Advertisement
cincout

Хан Соло и деньги

Apr 5th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. typedef long long ll;
  3. typedef double ld;
  4. using namespace std;
  5.  
  6. ll mas[150000];
  7.  
  8. void solve() {
  9. int j = 0;
  10. unordered_map <ll, ll> t;
  11. while (cin >> mas[j++]) {}
  12. j--;
  13. ll need = mas[j - 1];
  14. --j;
  15. for (int i = 0; i < j; ++i) t[mas[i]]++;
  16. for (int i = 0; i < j; ++i) {
  17. if ((need - mas[i] != mas[i] && t.count(need - mas[i]))) {
  18. cout << min(mas[i], need - mas[i]) << ' ' << need - min(mas[i], need - mas[i]);
  19. return;
  20. }
  21. else if (need - mas[i] == mas[i] && t[need - mas[i]] > 1) {
  22. cout << mas[i] << ' ' << mas[i];
  23. return;
  24. }
  25. }
  26. cout << -1;
  27. }
  28.  
  29. int main() {
  30. ios::sync_with_stdio(false);
  31. cin.tie(0);
  32. #ifdef arrias
  33. freopen("true.txt", "r", stdin);
  34. #endif
  35. solve();
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement