#include <iostream> #include "message.h" #include "teatr.h" #include "bits/stdc++.h" /* Autor: Helena Borak-Wejster */ using namespace std; int main(){ if(MyNodeId()==0){ long long int n = GetN(); long long int counter = 0; for(long long int i=0;i<n;i++){ for(long long int j=i+1;j<n;j++){ if(GetElement(i)>GetElement(j)) counter++; } } cout << counter << endl; } return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <iostream> #include "message.h" #include "teatr.h" #include "bits/stdc++.h" /* Autor: Helena Borak-Wejster */ using namespace std; int main(){ if(MyNodeId()==0){ long long int n = GetN(); long long int counter = 0; for(long long int i=0;i<n;i++){ for(long long int j=i+1;j<n;j++){ if(GetElement(i)>GetElement(j)) counter++; } } cout << counter << endl; } return 0; } |