#include <algorithm> #include <cstdio> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define INT(x) int x; scanf("%d", &x) typedef long long LL; int a[500000], b[500000]; int main() { INT(n); REP(i,n) scanf("%d", &a[i]); REP(i,n) b[i] = a[i]; sort(b, b + n); LL s = 0; int x = 0; REP(i,n) { if (!i) x = b[i] + 1; if (i && b[i] > b[i - 1] && b[i] >= s) x = b[i]; s += b[i]; } REP(i,n) putchar(a[i] >= x ? 'T' : 'N'); putchar('\n'); }
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 | #include <algorithm> #include <cstdio> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define INT(x) int x; scanf("%d", &x) typedef long long LL; int a[500000], b[500000]; int main() { INT(n); REP(i,n) scanf("%d", &a[i]); REP(i,n) b[i] = a[i]; sort(b, b + n); LL s = 0; int x = 0; REP(i,n) { if (!i) x = b[i] + 1; if (i && b[i] > b[i - 1] && b[i] >= s) x = b[i]; s += b[i]; } REP(i,n) putchar(a[i] >= x ? 'T' : 'N'); putchar('\n'); } |