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
55
56
57
58
59
60
61
62
63
64
65
#define ll long long
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;

ll tab[500007];
ll pos[500007];
ll zlicz[500007];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	bool nie=0;
	bool nie2=0;
	string s="";
	ll n,najw=0,k=0,p;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>tab[i];
		pos[i]=tab[i];
		najw=max(najw,tab[i]);
	}
	sort(pos,pos+n+1);
	
	for(int i=1;i<=n && nie2==0;i++){
		if(zlicz[i-1]>=najw){
			nie2=1;
			k=i-1;
		}
		else{
			zlicz[i]=zlicz[i-1]+pos[i];
		}
		
	}
	//cout<<k;
	
	//if(k==n)k--;
	
	for(int i=k;i>0 && nie==0;i--){
		if(pos[i]==pos[k])p=i;
		else{
			if(pos[i]+zlicz[i-1]<=pos[i+1]){
				nie=1;
				p=i;
			}
		}
	}
	//cout<<endl;
	for(int i=1;i<=n;i++){
		if(tab[i]<=pos[p])cout<<"N";
		else cout<<"T";
	}
	//cout<<endl;
	
	//for(int i=1;i<=n;i++)cout<<tab[i]<<" ";
	//cout<<endl;
	//for(int i=1;i<=n;i++)cout<<pos[i]<<" ";
	//cout<<endl;
	//for(int i=1;i<=n;i++)cout<<zlicz[i]<<" ";
	//cout<<endl;
	
	return 0;
}