#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { long n; cin >> n; vector<long> wagi; vector<long> kolejnosc; for (long i = 0; i < n; ++i) { long a; cin >> a; wagi.push_back(a); kolejnosc.push_back(a); } sort(wagi.begin(), wagi.end()); long sum_so_far = wagi[0]; long biggest_fish_possible = wagi[0]; long minwaga = wagi[0] + 1; for (long i = 1; i < n; ++i) { if (biggest_fish_possible <= wagi[i]) { minwaga = wagi[i]; } sum_so_far += wagi[i]; if (wagi[i] == wagi[0]) { biggest_fish_possible = wagi[0]; minwaga = wagi[i] + 1; } else { biggest_fish_possible = sum_so_far; } } for (long i = 0; i < n; ++i) { if (kolejnosc[i] < minwaga) { cout << "N"; } else { cout << "T"; } } cout << endl; 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 46 47 48 49 | #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { long n; cin >> n; vector<long> wagi; vector<long> kolejnosc; for (long i = 0; i < n; ++i) { long a; cin >> a; wagi.push_back(a); kolejnosc.push_back(a); } sort(wagi.begin(), wagi.end()); long sum_so_far = wagi[0]; long biggest_fish_possible = wagi[0]; long minwaga = wagi[0] + 1; for (long i = 1; i < n; ++i) { if (biggest_fish_possible <= wagi[i]) { minwaga = wagi[i]; } sum_so_far += wagi[i]; if (wagi[i] == wagi[0]) { biggest_fish_possible = wagi[0]; minwaga = wagi[i] + 1; } else { biggest_fish_possible = sum_so_far; } } for (long i = 0; i < n; ++i) { if (kolejnosc[i] < minwaga) { cout << "N"; } else { cout << "T"; } } cout << endl; return 0; } |