#include <bits/stdc++.h> #define INFINITY 1e15 using namespace std; long long n,a,sum,res; vector <long long> sumy,sorted; long long find_minim2 () { for(int i = 1; i < n; i++) { if(sorted[i-1] != sorted[i]) return sorted[i]; } return INFINITY; } int main() { cin >> n; for(int i = 0; i < n; i++) { cin >> a; sumy.push_back(a); } sorted = sumy; sort(sorted.begin(), sorted.end()); res = find_minim2(); for(int i = 0; i < n; i++) { if (sum <= sorted[i]) { res = max(res, sorted[i]); } sum += sorted[i]; } //cout << res << endl; for(int i = 0; i < n; i++) { if(sumy[i] < res) cout << "N"; else cout << "T"; } }
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 46 47 48 49 50 51 | #include <bits/stdc++.h> #define INFINITY 1e15 using namespace std; long long n,a,sum,res; vector <long long> sumy,sorted; long long find_minim2 () { for(int i = 1; i < n; i++) { if(sorted[i-1] != sorted[i]) return sorted[i]; } return INFINITY; } int main() { cin >> n; for(int i = 0; i < n; i++) { cin >> a; sumy.push_back(a); } sorted = sumy; sort(sorted.begin(), sorted.end()); res = find_minim2(); for(int i = 0; i < n; i++) { if (sum <= sorted[i]) { res = max(res, sorted[i]); } sum += sorted[i]; } //cout << res << endl; for(int i = 0; i < n; i++) { if(sumy[i] < res) cout << "N"; else cout << "T"; } } |