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
#include<bits/stdc++.h>

using namespace std;

int main(){
	int n; cin>>n;
	vector<pair<int, int>> v(n);
	long long sum = 0;
	for(int i = 0; i < n; i++){
		int a; cin>>a;
		v[i] = {a, i};
		sum += a;
	}
	vector<bool> possible(n, false);
	sort(v.begin(), v.end());
	possible[v[n-1].second] = true;
	sum -= v[n-1].first;
	int j = n-2;
	while(j >= 0 && sum > v[j+1].first){
		possible[v[j].second] = true;
		sum -= v[j].first;
		j--;
	}
	if(j>=0){
		for(int i = 0; i < n; i++){
			if(v[i].first == v[j].first)possible[v[i].second] = false;
		}
	}
	for(int i = 0; i < n; i++){
		if(possible[i])cout<<"T";
		else cout<<"N";
	}
	cout<<"\n";
}