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
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second

int main(){
	int n;
	cin >> n;
	vector<int> t(n);
	map<int, vector<int>> mapa;
	int gr = 1e9;

	for(int i=0,a; i<n; i++){
		cin >> a;
		t[i] = a;
		mapa[a].push_back(i);
		gr = min(gr,a);
	}
	long long pref = 0;
	for(auto e : mapa){
		if(pref <= (long long)e.F)
			gr = max(gr,e.F - 1);
		pref += (long long)e.S.size() * (long long)e.F;
	}
	for(int e : t)
		if(e <= gr)
			cout << "N";
		else 
			cout << "T";
	cout << "\n";
}