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
#include <cstdio>
#include <algorithm>

typedef long long ll;
typedef struct sum {
  int val;
  int pos;
} sum;   

bool compare_val;

bool operator<(const sum &A, const sum &B) {
  if (compare_val) return A.val < B.val;
  return A.pos < B.pos;
}

#define MAXN 500050

sum sums[MAXN];

int N;
int main() {
  scanf("%d", &N);  
  for (int i = 0; i < N; ++i) {
    sums[i].pos = i;
    scanf("%d", &sums[i].val);
  }
  compare_val = true;
  std::sort(&sums[0], &sums[N]);
  ll cureat = 0;
  int failfish = 0;
  for (int i = 0; i < N - 1; ++i) {
    cureat += sums[i].val;
    if (cureat <= sums[i+1].val) failfish = sums[i].val;
  } 
  compare_val = false;
  std::sort(&sums[0], &sums[N]);
  for (int i = 0; i < N; ++i) {
    printf("%c", sums[i].val <= failfish ? 'N' : 'T');
  }
  printf("\n"); 
  return 0;
}