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
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    std::ios::sync_with_stdio(false); std::cin.tie();

    int n; cin >> n;
    vector<pair<ll, int>> fish;
    vector<bool> king(n);
    ll total = 0;
    ll smol = 2137213769;
    for (int i = 0; i < n; i++) {
        ll v; cin >> v;
        total += v;
        fish.push_back({v, i});
        smol = min(smol, v);
    }

    sort(fish.begin(), fish.end(), greater<pair<ll, int>>());

    ll prev = 0;
    for (auto [v, i] : fish) {
        if (total > prev && v != smol) king[i] = true;
        else break;
        total -= v;
        prev = v;
    }

    if (n == 1) king[0] = true;

    for (bool x : king) {
        cout << (x ? 'T' : 'N');
    }

    cout << '\n';
}