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
49
50
51
52
53
54
55
56
57
/***********PA 2021***********/
/******Autor: Jakub Bąba******/

#include <bits/stdc++.h>
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n, min = 1000000001, i, input; long long sum, dodod = 0;
  vector<int> a, lista;

  cin >> n;
  for (i=0; i<n; i++)
  {
    cin >> input;
    lista.push_back(input);
    a.push_back(input);
  }

  sort(a.begin(), a.end());

  sum = a[0];
  for (i=1; i<n; i++)
  {
    if (sum == a[i] && a[i] == a[i-1])
      dodod += a[i];
    else
    {
      if (sum <= a[i])
        min = a[i];
      sum += a[i] + dodod;
      dodod = 0;
    }
    // if (a[i] > a[i-1])
    // {
    //   if (sum<=a[i])
    //     min = a[i];
    //   sum += a[i] + dodod;
    //   dodod = 0;
    // }
    // else
    //   dodod += a[i];
  }

  for (i=0; i<n; i++)
  {
    if (lista[i] >= min)
      cout << "T";
    else
      cout << "N";
  }

  return 0;
}