Submission #1030680

#TimeUsernameProblemLanguageResultExecution timeMemory
1030680ZicrusArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include "shoes.h" using namespace std; typedef long long ll; ll count_swaps(vector<int> a) { ll n = a.size() / 2; vector<ll> leftPos; ll res = 0; for (int i = 0; i < a.size(); i++) { if (a[i] < 0) leftPos.push_back(i); } for (int i = 0; i < n; i++) { res += abs(leftPos[i] - 2*i); } return res; }

Compilation message (stderr)

shoes.cpp: In function 'll count_swaps(std::vector<int>)':
shoes.cpp:10:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int i = 0; i < a.size(); i++) {
      |                     ~~^~~~~~~~~~
shoes.cpp:14:16: error: 'abs' was not declared in this scope
   14 |         res += abs(leftPos[i] - 2*i);
      |                ^~~