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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> A(n);
	for (auto &a: A) {
		cin >> a;
	}
	vector<int> B=A;
	sort(B.begin(), B.end());
	long long cum = 0;
	long long cumsum = 0;
	int fc = -1;
	for (int i=0; i<n; i++) {
		if (i>0) {
			if (B[i-1] + cumsum > B[i]) {
				if (fc < 0) fc = B[i-1];
			} else {
				fc = -1;
			}
			if (B[i-1] + cumsum > B[i] || B[i] > B[i-1]) {
				if (fc < 0) fc = B[i];
				cumsum += cum;
				cum = 0;
			}
		}
		cum += B[i];
	}
	for (auto a: A) cout << (fc < 0 || a < fc ? "N" : "T");
	cout << endl;
	return 0;
}