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
#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>


using namespace std;

constexpr int maxx = 2'000'000'000;

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

    int n;
    cin>>n;

    vector<int> a;
    copy_n(istream_iterator<int>(cin),n,back_inserter(a));

    vector<int> sa(a);
    sort(begin(sa), end(sa));
    sa.push_back(sa.back());

    int64_t cumsum =sa[0];
    int min_krol=maxx;
    int i=1;
    while(sa[i]==sa[0]){
        cumsum+=sa[0];
        i++;
    }
    for (; i<n; i++) {
        cumsum+=sa[i];
        if (cumsum>sa[i+1]){
            min_krol = min(min_krol,sa[i]);
        }else
            min_krol = maxx;
    }

    transform( begin(a), end(a), ostream_iterator<char>(cout), [min_krol](int r) {return r>=min_krol?'T':'N';}  );

    return 0;
}