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
52
53
54
#include <bits/stdc++.h>
using namespace std;

unsigned long long tab[500005]={};
vector <pair <unsigned long long, unsigned long long> > v;
vector <pair <unsigned long long, unsigned long long> > zlicz;
unsigned long long n, a, MIN;

int main()
{
	ios_base::sync_with_stdio(0);
	
	cin >> n;
	
	for (int i=0; i<n; i++)
	{
		cin >> a;
		tab[i]=a;
		v.push_back(make_pair(a, i));
	}
	
	sort(v.begin(), v.end());
	
	zlicz.push_back(make_pair(v[0].first, v[0].first));
	
	for (int i=1; i<v.size(); i++)
	{
		if (v[i].first!=v[i-1].first)
			zlicz.push_back(make_pair(zlicz[zlicz.size()-1].first, v[i].first));
		
		zlicz[zlicz.size()-1].first+=v[i].first;
	}
	
	MIN=v[0].first;
	a=zlicz[zlicz.size()-1].second;
	
	for (int i=zlicz.size()-1; i>=1; i--)
	{
		if (zlicz[i].second<zlicz[i-1].first)
			a=zlicz[i-1].second;
		else
			break;
	}
	
	for (int i=0; i<n; i++)
	{
		if (tab[i]>=a && tab[i]!=MIN)
			cout << "T";
		else
			cout << "N";
	}
	
	return 0;
}