Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- ios::sync_with_stdio(0);
- int n;
- cin >> n;
- long long mn = 1e9, sum = 0;
- vector<vector<int>> os(10, vector<int>(10, 1e9));
- cout << os[0][2];
- for (int i = 0; i < n; i++) {
- long long dop1, dop2;
- cin >> dop1 >> dop2;
- sum += min(dop1, dop2);
- int os_ = abs(dop1 - dop2);
- for (int i = 0; i < 10; i++) {
- if (os_ < os[os_ % 10][i]) {
- int dop3 = os_;
- os_ = os[dop3 % 10][i];
- os[dop3 % 10][i] = dop3;
- }
- }
- }
- cout << "==============\n";
- cout << sum << endl;
- cout << " | \n--V--\n->" << sum % 10 << "<-\n=====\n";
- for (int i = 1; i < 10; i++) {
- cout << "os = " << i << endl;
- for (int j = 0; j < 10; j++) {
- if (os[i][j] != 1000000000) {
- cout << os[i][j] << ' ';
- }
- else {
- cout << "- ";
- }
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement