#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
scanf("%d", &n);
vector<int> a(n);
for (int& x : a)
scanf("%d", &x);
vector<int> b = a;
sort(a.rbegin(), a.rend());
int64_t s = 0;
for (int x : a)
s += x;
int y = 0;
for (int x : a) {
if (x == a.back() || s <= y)
break;
y = x;
s -= x;
}
for (int x : b)
putchar(y == 0 || x < y ? 'N' : 'T');
putchar('\n');
return 0;
}
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 | #include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); vector<int> a(n); for (int& x : a) scanf("%d", &x); vector<int> b = a; sort(a.rbegin(), a.rend()); int64_t s = 0; for (int x : a) s += x; int y = 0; for (int x : a) { if (x == a.back() || s <= y) break; y = x; s -= x; } for (int x : b) putchar(y == 0 || x < y ? 'N' : 'T'); putchar('\n'); return 0; } |
English