Submission #282456

#TimeUsernameProblemLanguageResultExecution timeMemory
282456Ruba_KArranging Shoes (IOI19_shoes)C++14
50 / 100
1094 ms3200 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std ; long long count_swaps(vector<int> v) { int n = v.size() ; long long ans = 0 ; for(;!v.empty();){ int i = v.size() - 1; int idx = i - 1 ; while(v[idx] != v[i] * -1){ idx -- ; ans ++ ; } v.erase(v.begin() + idx); if(v[i] < 0)ans ++ ; v.pop_back(); } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:6:9: warning: unused variable 'n' [-Wunused-variable]
    6 |     int n = v.size() ;
      |         ^
#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...