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

long long n, a, suma, wyn[100000], sumy[1000000], pom;
vector <pair <long long, long long>> tab;
int main()
{
	cin>>n;
	for(int i=0; i<n; i++) 
	{
		cin>>a;
		tab.push_back(make_pair(a, i));
	}
	sort(tab.begin(), tab.end());
	suma = tab[0].first;
	sumy[0] = 0;
	for(int i=1; i<n-1; i++)
	{
		pom = i-1;
		while (tab[i].first == tab[pom].first) pom--;
		sumy[i] = sumy[pom] + tab[i].first;
		if (sumy[i] > tab[i+1].first) wyn[tab[i].second] = 1;
		else wyn[tab[i].second] = 0;
	}
	wyn[tab[n-1].second] = 1;
	for(int i=0; i<n; i++)
	{
		if (wyn[i] == 0) cout<<"N";
		else cout<<"T";
		
	}
	
}