diff --git a/Section 05 - sorting and searching/icpcStandings_nlogn.cpp b/Section 05 - sorting and searching/icpcStandings_nlogn.cpp new file mode 100644 index 0000000..5c594e1 --- /dev/null +++ b/Section 05 - sorting and searching/icpcStandings_nlogn.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; + +bool compare(paira, pair b){ + return a.second < b.second; +} + +int badness(vector > teams){ + //Complete this function to return the min badness + sort(teams.begin(), teams.end(), compare); + int cnt = 0; + for(int i = 0; i < teams.size(); i++){ + int j = i+1; + cnt += abs(teams[i].second-j); + } + return cnt; +} \ No newline at end of file