Submission #985548

#TimeUsernameProblemLanguageResultExecution timeMemory
985548LucaIlieArranging Shoes (IOI19_shoes)C++17
10 / 100
22 ms5712 KiB
#include "shoes.h" using namespace std; #define nmax 100000 int v[nmax]; int n; int find_pair( int l ) { int i; if( v[l] < 0 ) { for( i = l + 1; i < n; i++ ) { if( v[i] + v[l] == 0 ) break; } swap( v[l + 1], v[i] ); return i - l - 1; } else { for( i = l + 1; i < n; i++ ) { if( v[i] + v[l] == 0 ) break; } swap( v[l + 1], v[i] ); return i - l; } } long long count_swaps( vector<int> s) { int i, l, rez = 0; n = s.size(); for( i = 0; i < n; i++ ) v[i] = s[i]; for( l = 0; l < n; l += 2 ) { rez += find_pair( l ); } return rez; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...