Submission #985566

#TimeUsernameProblemLanguageResultExecution timeMemory
985566LucaIlieArranging Shoes (IOI19_shoes)C++17
50 / 100
23 ms5060 KiB
#include "shoes.h" using namespace std; #define nmax 100000 int v[nmax]; int n; int find_pair( int l ) { int i, j; if( v[l] < 0 ) { for( i = l + 1; i < n; i++ ) { if( v[i] + v[l] == 0 ) break; } for( j = i; j > l + 1; j-- ) v[j] = v[j - 1]; return i - l - 1; } else { for( i = l + 1; i < n; i++ ) { if( v[i] + v[l] == 0 ) break; } for( j = i; j > l + 1; j-- ) v[j] = v[j - 1]; 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...