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
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n = 1, to_small;
  cin >> n;
  vector<int> v(n);
  for(int i = 0, x;i < n;i++)
    cin >> v[i];
  if (n == 1){
    cout << "T";
    return 0;
  }
  vector<int> t = v;
  vector<pair<int, int>> u;
  sort(v.begin(), v.end());
  for(auto i : v){
    if(!u.empty() && i == u.back().first)
      u.back().second++;
    else
      u.emplace_back(i, 1);
  }
  to_small = v[0];
  long long sum = u[0].first * u[0].second;
  for(int i = 1;i < u.size() - 1;i++){
    sum += u[i].first * u[i].second;
    if(sum <= u[i + 1].first)
      to_small = u[i].first;
  }
  for(auto i : t) cout << (i <= to_small ? "N" : "T");
}