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
//#include "pch.h"
#include <iostream>
#include <algorithm>
using namespace std;
bool sortes(pair<long long, int> a, pair<long long, int> b)
{
	return a.first < b.first;
}
const int maxik = 500007;
int out[maxik];
pair<long long, int> fishes[maxik];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int hm;
	cin >> hm;
	int last=0;
	for (int i = 1; i <= hm; i++)
	{
		cin >> fishes[i].first;
		out[i]= fishes[i].first;
		fishes[i].second = i;
	}
	sort(fishes + 1, fishes + 1 + hm, sortes);
	for (int i = 1; i < hm; i++)
	{
		fishes[i].first += fishes[i - 1].first;
		if ( fishes[i].first<=fishes[i+1].first )
		{
			last = out[fishes[i].second];
		}
		
	}
	
	for (int i = 1; i <= hm; i++)
	{
		if (out[i] > last)
		{
			cout << "T";
		}
		else
		{
			cout << "N";
		}
	}
	//system("pause");
}