#include <cstdio> #include <vector> #include <algorithm> typedef long long LL; using namespace std; int main() { int n; scanf("%d", &n); vector<int> a(n); for (int i=0; i<n; ++i) scanf("%d", &a[i]); vector<int> b(a); sort(b.begin(), b.end()); int not_ok = 0; LL sum = 0; for (int i=0; i<n; ++i) { if (b[i] <= b[0]) { not_ok = b[i]; continue; } sum += b[i]; if (i+1 < n && sum <= b[i+1]) { not_ok = b[i]; continue; } } for (int i=0; i<n; ++i) { if (a[i] <= not_ok) { printf("N"); } else { printf("T"); } } printf("\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 29 30 31 32 33 34 35 36 37 38 39 40 41 | #include <cstdio> #include <vector> #include <algorithm> typedef long long LL; using namespace std; int main() { int n; scanf("%d", &n); vector<int> a(n); for (int i=0; i<n; ++i) scanf("%d", &a[i]); vector<int> b(a); sort(b.begin(), b.end()); int not_ok = 0; LL sum = 0; for (int i=0; i<n; ++i) { if (b[i] <= b[0]) { not_ok = b[i]; continue; } sum += b[i]; if (i+1 < n && sum <= b[i+1]) { not_ok = b[i]; continue; } } for (int i=0; i<n; ++i) { if (a[i] <= not_ok) { printf("N"); } else { printf("T"); } } printf("\n"); return 0; } |