Language: C++


int main()
{
	int a, b, q;
	std::cin >> a >> b >> q;
	std::vector<int> s(a);
	std::vector<int> t(b);
	std::vector<int> x(q);
	for (int i = 0; i < a; i++) {
		std::cin >> s[i];
	}
	for (int i = 0; i < b; i++) {
		std::cin >> t[i];
	}
	for (int i = 0; i < q; i++) {
		std::cin >> x[i];
	}

	for (int i = 0; i < q; i++) {
		int cur_pos = x[i];
		int min_ad = 10e10;
		int min_aind = -1;
		for (int j = 0; j < a; j++) {
			int ad = abs(s[j] - cur_pos);
			if (min_ad > ad) {
				min_ad = ad;
				min_aind = j;
			}
		}

		int min_bd = 10e10;
		int min_bind = -1;
		for (int j = 0; j < b; j++) {
			int bd = abs(t[j] - cur_pos);
			if (min_bd > bd) {
				min_bd = bd;
				min_bind = j;
			}
		}

		int sum[2]={0,0};
		{
			sum[0] += min_bd;
			cur_pos = t[min_bind];
			int _min_ad = 10e10;
			int _min_aind = -1;
			for (int j = 0; j < a; j++) {
				int ad = abs(s[j] - cur_pos);
				if (_min_ad > ad) {
					_min_ad = ad;
					_min_aind = j;
				}
			}
			sum[0] += _min_ad;
		}
		{
			sum[1] += min_ad;
			cur_pos = s[min_aind];
			int _min_bd = 10e10;
			int _min_bind = -1;
			for (int j = 0; j < b; j++) {
				int bd = abs(t[j] - cur_pos);
				if (_min_bd > bd) {
					_min_bd = bd;
					_min_bind = j;
				}
			}
			sum[1] += _min_bd;
		}
		if (sum[0] > sum[1]) {
			std::cout << sum[1] << std::endl;
		}
		else {
			std::cout << sum[0] << std::endl;
		}
	}	
	return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:14: error: 'cin' is not a member of 'std'
    5 |         std::cin >> a >> b >> q;
      |              ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | 
a.cc:6:14: error: 'vector' is not a member of 'std'
    6 |         std::vector<int> s(a);
      |              ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | 
a.cc:6:21: error: expected primary-expression before 'int'
    6 |         std::vector<int> s(a);
      |                     ^~~
a.cc:7:14: error: 'vector' is not a member of 'std'
    7 |         std::vector<int> t(b);
      |              ^~~~~~
a.cc:7:14: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:7:21: error: expected primary-expression before 'int'
    7 |         std::vector<int> t(b);
      |                     ^~~
a.cc:8:14: error: 'vector' is not a member of 'std'
    8 |         std::vector<int> x(q);
      |              ^~~~~~
a.cc:8:14: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:8:21: error: expected primary-expression before 'int'
    8 |         std::vector<int> x(q);
      |                     ^~~
a.cc:10:22: error: 'cin' is not a member of 'std'
   10 |                 std::cin >> s[i];
      |                      ^~~
a.cc:10:22: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:10:29: error: 's' was not declared in this scope
   10 |                 std::cin >> s[i];
      |                             ^
a.cc:13:22: error: 'cin' is not a member of 'std'
   13 |                 std::cin >> t[i];
      |                      ^~~
a.cc:13:22: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:13:29: error: 't' was not declared in this scope
   13 |                 std::cin >> t[i];
      |                             ^
a.cc:16:22: error: 'cin' is not a member of 'std'
   16 |                 std::cin >> x[i];
      |                      ^~~
a.cc:16:22: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:16:29: error: 'x' was not declared in this scope
   16 |                 std::cin >> x[i];
      |                             ^
a.cc:20:31: error: 'x' was not declared in this scope
   20 |                 int cur_pos = x[i];
      |                               ^
a.cc:21:30: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+11' to '2147483647' [-Woverflow]
   21 |                 int min_ad = 10e10;
      |                              ^~~~~
a.cc:24:38: error: 's' was not declared in this scope
   24 |                         int ad = abs(s[j] - cur_pos);
      |                                      ^
a.cc:24:34: error: 'abs' was not declared in this scope
   24 |                         int ad = abs(s[j] - cur_pos);
      |                                  ^~~
a.cc:31:30: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+11' to '2147483647' [-Woverflow]
   31 |                 int min_bd = 10e10;
      |                              ^~~~~
a.cc:34:38: error: 't' was not declared in this scope
   34 |                         int bd = abs(t[j] - cur_pos);
      |                                      ^
a.cc:34:34: error: 'abs' was not declared in this scope
   34 |                         int bd = abs(t[j] - cur_pos);
      |                                  ^~~
a.cc:44:35: error: 't' was not declared in this scope
   44 |                         cur_pos = t[min_bind];
      |                                   ^
a.cc:45:39: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+11' to '2147483647' [-Woverflow]
   45 |                         int _min_ad = 10e10;
      |                                       ^~~~~
a.cc:48:46: error: 's' was not declared in this scope
   48 |                                 int ad = abs(s[j] - cur_pos);
      |                                              ^
a.cc:48:42: error: 'abs' was not declared in this scope
   48 |                                 int ad = abs(s[j] - cur_pos);
      |                                          ^~~
a.cc:58:35: error: 's' was not declared in this scope
   58 |                         cur_pos = s[min_aind];
      |                                   ^
a.cc:59:39: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+11' to '2147483647' [-Woverflow]
   59 |                         int _min_bd = 10e10;
      |                                       ^~~~~
a.cc:62:46: error: 't' was not declared in this scope
   62 |                                 int bd = abs(t[j] - cur_pos);
      |                                              ^
a.cc:62:42: error: 'abs' was not declared in this scope
   62 |                                 int bd = abs(t[j] - cur_pos);
      |                                          ^~~
a.cc:71:30: error: 'cout' is not a member of 'std'
   71 |                         std::cout << sum[1] << std::endl;
      |                              ^~~~
a.cc:71:30: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:71:53: error: 'endl' is not a member of 'std'
   71 |                         std::cout << sum[1] << std::endl;
      |                                                     ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | 
a.cc:74:30: error: 'cout' is not a member of 'std'
   74 |                         std::cout << sum[0] << std::endl;
      |                              ^~~~
a.cc:74:30: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:74:53: error: 'endl' is not a member of 'std'
   74 |                         std::cout << sum[0] << std::endl;
      |                                                     ^~~~
a.cc:74:53: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'