# My solution for SRM 306 DIV2 [250]

Problem Statement: http://www.topcoder.com/stat?c=problem_statement&pm=6413&rd=9986

My solution:

#include <iostream>
#include <vector>

using namespace std;

class SortMachine  {

public:
SortMachine () {}

public:
int countMoves(vector <int> a) {
int countMove = 0;

while(1) {
int move = -1;
int minInversion = 1001;

for (unsigned int i = 0; i < a.size() - 1; ++i) {
for (unsigned int j = i + 1; j < a.size(); ++j) {
if (a[i] > a[j] && a[i] < minInversion) {
move = i;
minInversion = a[i];
break;
}
}
}

if (move == -1) {
break;
}

int temp = a[move];
for (unsigned int i = move; i < a.size() - 1; ++i) {
a[i] = a[i + 1];
}
a[a.size() - 1] = temp;

++countMove;
}

return countMove;
}
};

#### SRM 512 div2 512point

2011-07-14 12:38:34

#### SRM 598 DIV2 1000 FoxAndFencingEasy

2013-11-29 17:22:36

#### SRM 649 div2 1000

2015-02-12 18:31:42

#### SRM 599 div2 250 500

2013-12-05 10:14:41

#### srm 556 div2

2012-09-14 22:00:51

#### SRM602 (div2)

2013-12-29 15:13:48

#### 记第一次SRM （SRM489 div2）

2010-12-01 09:41:00

#### SRM145_DIV2

2016-10-24 09:08:27

#### SRM 145 DIV 2 250

2016-10-19 00:35:25

#### SRM 399 DIV2 [250]

2008-04-26 15:05:00