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
51
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;

const int MAX_N = 500000;
const int MAX_SUM = 1000000000;
int n;
pair<int, int> sumy[MAX_N];
int value;
long long maxzsum, sumofsum;

bool cmpfi(pair<int, int> &a, pair<int, int> &b)
{
	if (a.first < b.first)return true;
	return false;
}


bool cmpse(pair<int, int> &a, pair<int, int> &b)
{

	if (a.second < b.second)return true;
	return false;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> value;
		sumy[i] = make_pair(i, value);
	}
	sort(sumy, sumy + n, cmpse);
	maxzsum = 0;
	sumofsum = sumy[0].second;
	for (int i = 1; i < n; i++)
	{
		if (sumy[i].second >= sumofsum)maxzsum = sumy[i - 1].second;
		sumofsum += sumy[i].second;
		if (MAX_SUM < sumofsum)break;
	}
	sort(sumy, sumy + n , cmpfi);
	for (int i = 0; i < n; i++)
	{
		if (maxzsum >= sumy[i].second)cout << "N";
		else cout << "T";
	}
}