Advertisement
9I_HE_TbI_A_9I

Untitled

Oct 20th, 2021
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. ios::sync_with_stdio(0);
  10. int n;
  11. cin >> n;
  12. long long mn = 1e9, sum = 0;
  13. vector<vector<int>> os(10, vector<int>(10, 1e9));
  14. cout << os[0][2];
  15. for (int i = 0; i < n; i++) {
  16. long long dop1, dop2;
  17. cin >> dop1 >> dop2;
  18. sum += min(dop1, dop2);
  19. int os_ = abs(dop1 - dop2);
  20. for (int i = 0; i < 10; i++) {
  21. if (os_ < os[os_ % 10][i]) {
  22. int dop3 = os_;
  23. os_ = os[dop3 % 10][i];
  24. os[dop3 % 10][i] = dop3;
  25. }
  26. }
  27. }
  28. cout << "==============\n";
  29. cout << sum << endl;
  30. cout << " | \n--V--\n->" << sum % 10 << "<-\n=====\n";
  31. for (int i = 1; i < 10; i++) {
  32. cout << "os = " << i << endl;
  33. for (int j = 0; j < 10; j++) {
  34. if (os[i][j] != 1000000000) {
  35. cout << os[i][j] << ' ';
  36. }
  37. else {
  38. cout << "- ";
  39. }
  40. }
  41. cout << endl;
  42. }
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement