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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

vector <int> fishes, solve;

int main() 
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, solution = 0;
    long long sum = 0; 
    bool w = false;
    cin >> n;
    fishes.resize(n);
    cin >> fishes[0];
    for(int i = 1; i < n; ++i)
    {
        cin >> fishes[i];
        if(fishes[i] != fishes[i-1])
        {
            w = true;
        }
    }
    solve = fishes;
    sort(fishes.begin(), fishes.end());
    sum = fishes[0];
    for(int i = 1; i < n-1; ++i)
    {
        sum += fishes[i];
        if(sum > fishes[n-1])
        {
            if(fishes[i] == fishes[i-1])
            {
                if(fishes[i] > fishes[0])
                {
                    solution = fishes[i];
                }
                else
                {
                    solution = fishes[i+1];
                }
            }
            else
            {
                solution = fishes[i];
            }
            break;
        }
        
    }
    if(w == true)
    {
        if(solution == 0)
        {
            solution = fishes[n-1];
        }
    }
    else
    {
        solution = fishes[n-1]+10;
    }
    
    for(int  i = 0; i < n; ++i)
    {
        if(solve[i] >= solution)
        {
            cout << "T";
        }
        else
        {
            cout << "N";
        }
    }
}