제출 #397877

#제출 시각아이디문제언어결과실행 시간메모리
397877snasibov05Arranging Shoes (IOI19_shoes)C++14
컴파일 에러
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) {
        ans += abs(*st.begin() - i);
        st.erase(st.begin());
    }

    return ans;

}

컴파일 시 표준 에러 (stderr) 메시지

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