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
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <climits>

using namespace std;

long a[500002];
long b[500002];

int main()
{
	long n;
	scanf("%ld", &n);
	for (long i = 0; i < n; ++i)
	{
		scanf("%ld", &a[i]);
	}
	copy(a, a + n, b);
	sort(b, b + n);
	b[n] = 0;
	long res = LONG_MAX, sum = b[0];
	for (long i = 1; i < n; ++i)
	{
		sum += b[i];
		if (b[i] > b[0] && sum > b[i + 1])
		{
			if (res == LONG_MAX)
				res = b[i];
		}
		else
			res = LONG_MAX;
	}

	for (long i = 0; i < n; ++i)
		printf("%c", a[i] < res ? 'N' : 'T');
	return 0;
}