Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <algorithm>
- using std::cin;
- using std::cout;
- using std::ifstream;
- using std::vector;
- using std::sort;
- using std::max;
- int divide(vector<int> input, int left, int right) {
- int nr = 0;
- vector<int> bck = input;
- sort(input.begin(), input.end(), [](int a, int b) {
- return a < b;
- });
- for (int i = 0; i < input.size(); i++) {
- if (bck[i] != input[i]) nr++;
- }
- return nr;
- }
- int main(){
- ifstream in("input.in");
- vector<int> input; int x;
- while (in >> x) {
- input.push_back(x);
- }
- cout << divide(input, 0, input.size() - 1);
- }
- //input: 1 2 9 11 4 6 10 15
- //output: 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement