#include <cstdio> #include <algorithm> int main () { int n; scanf ("%i", &n); int A[n], I[n], k = 0; for (int i=0; i<n; i++) scanf ("%i", &A[i]), I[i] = i; std::sort (I, I+n, [&] (int a, int b) {return A[a]<A[b];}); long long S[n], s = 0; for (int i=0; i<n; i++) S[i] = s, k = A[I[i]], s += k++; for (int i=n-1; i>=0; i--) { if (A[I[i]]==A[I[0]]) break; k = A[I[i]]; if (A[I[i]]>=S[i]) break; } for (int i=0; i<n; i++) putchar ("NT"[A[i]>=k]); puts (""); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <cstdio> #include <algorithm> int main () { int n; scanf ("%i", &n); int A[n], I[n], k = 0; for (int i=0; i<n; i++) scanf ("%i", &A[i]), I[i] = i; std::sort (I, I+n, [&] (int a, int b) {return A[a]<A[b];}); long long S[n], s = 0; for (int i=0; i<n; i++) S[i] = s, k = A[I[i]], s += k++; for (int i=n-1; i>=0; i--) { if (A[I[i]]==A[I[0]]) break; k = A[I[i]]; if (A[I[i]]>=S[i]) break; } for (int i=0; i<n; i++) putchar ("NT"[A[i]>=k]); puts (""); return 0; } |