Submission #1274972

#TimeUsernameProblemLanguageResultExecution timeMemory
1274972rafsanamin2020Arranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "shoes.h"

long long count_swaps(std::vector<int> s)
{
	int N = s.size(), p = 0, n = 0;

	for (int i = 0; i < N; i += 2)
	{
		if (s[i] > 0)
		{
			p++;
		}
		else if (s[i + 1] < 0)
		{
			n--;
		}
	}

	return max(p, n);
}

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:20:16: error: 'max' was not declared in this scope
   20 |         return max(p, n);
      |                ^~~
shoes.cpp:20:16: note: suggested alternatives:
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from shoes.cpp:1:
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   'std::max'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /usr/include/c++/13/algorithm:63:
/usr/include/c++/13/bits/ranges_algo.h:2928:29: note:   'std::ranges::max'
 2928 |   inline constexpr __max_fn max{};
      |                             ^~~