diff --git a/SolutionToStickLengthsProblem.txt b/SolutionToStickLengthsProblem.txt new file mode 100644 index 0000000..a0e45d7 --- /dev/null +++ b/SolutionToStickLengthsProblem.txt @@ -0,0 +1,23 @@ +#include +using namespace std; + +int main() +{ + long long a, c = 0; + cin >> a; + int b[a]; + + for (int i; i < a; i++){ + cin >> b[i]; + } + + sort(b, b + a); + + for(int i; i < a; i++){ + c += abs(b[a/2] - b[i]); + } + + cout << c; + + return 0; +} \ No newline at end of file