1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <algorithm>
#include <stdio.h>
#include <vector>

int solution(std::vector<int> sharks)
{
	std::sort(sharks.begin(), sharks.end());
	const auto minShark = sharks.front();
	int lowestShark;
	long long int buffer{0};
	for (const auto shark : sharks)
	{
		if (shark == minShark)
		{
			buffer += shark;
			lowestShark = shark + 1;
		}
		else
		{
			if (buffer <= shark)
			{
				lowestShark = shark;
			}
			buffer += shark;
		}
	}
	return lowestShark;
}

int main()
{
	int n, shark;
	scanf("%d\n", &n);
	std::vector<int> sharks;
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &shark);
		sharks.push_back(shark);
	}
	const auto s = solution(sharks);
	for (const auto sum : sharks)
	{
		if (s <= sum)
			printf("T");
		else
			printf("N");
	}
	printf("\n");
	return 0;
}