#include <bits/stdc++.h> constexpr int W=20, N=10'000; struct zaw { bool c; char x; }; int main() { std::vector<int> r; r.reserve(W); int n; zaw t[N]; scanf("%d", &n); for (int i=0; i!=n; ++i) { char s[4]; scanf("%s", s); t[i].c = s[0]=='T'; scanf("%hhd", &t[i].x); } for (int i=0; (i!=n) && (r.size()<10); ++i) { if (t[i].c) { t[i].c = false; r.push_back(i+1); } } for (int i=0; (i!=n) && (r.size()<20); ++i) { if (t[i].c && (t[i].x<2)) { r.push_back(i+1); } } std::sort(r.begin(), r.end()); for (auto it=r.begin(); it!=r.end(); ++it) { printf("%d ", *it); } 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 | #include <bits/stdc++.h> constexpr int W=20, N=10'000; struct zaw { bool c; char x; }; int main() { std::vector<int> r; r.reserve(W); int n; zaw t[N]; scanf("%d", &n); for (int i=0; i!=n; ++i) { char s[4]; scanf("%s", s); t[i].c = s[0]=='T'; scanf("%hhd", &t[i].x); } for (int i=0; (i!=n) && (r.size()<10); ++i) { if (t[i].c) { t[i].c = false; r.push_back(i+1); } } for (int i=0; (i!=n) && (r.size()<20); ++i) { if (t[i].c && (t[i].x<2)) { r.push_back(i+1); } } std::sort(r.begin(), r.end()); for (auto it=r.begin(); it!=r.end(); ++it) { printf("%d ", *it); } printf("\n"); return 0; } |