Submission #397882

#TimeUsernameProblemLanguageResultExecution timeMemory
397882snasibov05Arranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" #include <set> using namespace std; long long count_swaps(vector<int> s) { long long ans = 0; int n = s.size(); set<int> st; for (int i = 1; i < n; i += 2) { if (s[i] < 0) st.insert(i); } for (int i = 0; i < n; i += 2) { if (s[i] < 0) continue; ans += abs(*st.begin() - i); st.erase(st.begin()); } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:17:16: error: 'abs' was not declared in this scope; did you mean 'ans'?
   17 |         ans += abs(*st.begin() - i);
      |                ^~~
      |                ans