#include <bits/stdc++.h>
using namespace std;
int n, a[500000], t[500000];
unsigned long long x=0, r, d=0;
int main() {
scanf("%d", &n);
for (int i=0; i^n; ++i) {
scanf("%d", &a[i]);
t[i] = a[i];
}
sort(t, t+n);
if (t[0]==t[n-1]) {
for (int i=0; i^n; ++i) {
printf("N");
}
return 0;
}
for (int i=0; i^n; ++i) {
if (t[i]>x) {
x += t[i];
x += d;
d = 0;
r = t[i];
} else {
if (x>t[i]) {
x += t[i];
x += d; // te dwie linie nic nie robio
d = 0;
} else { // x==t[i]
d += t[i];
r = t[i];
}
}
}
for (int i=0; i^n; ++i) {
if (a[i]>=r) {
printf("T");
} else {
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 42 43 44 45 | #include <bits/stdc++.h> using namespace std; int n, a[500000], t[500000]; unsigned long long x=0, r, d=0; int main() { scanf("%d", &n); for (int i=0; i^n; ++i) { scanf("%d", &a[i]); t[i] = a[i]; } sort(t, t+n); if (t[0]==t[n-1]) { for (int i=0; i^n; ++i) { printf("N"); } return 0; } for (int i=0; i^n; ++i) { if (t[i]>x) { x += t[i]; x += d; d = 0; r = t[i]; } else { if (x>t[i]) { x += t[i]; x += d; // te dwie linie nic nie robio d = 0; } else { // x==t[i] d += t[i]; r = t[i]; } } } for (int i=0; i^n; ++i) { if (a[i]>=r) { printf("T"); } else { printf("N"); } } return 0; } |
English