#include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; vector< pair<int,int> > possible; for (int i = 0; i<n; i++) { string s; cin >> s; int x; cin >> x; if(s[0]=='T') { possible.push_back(make_pair(i, x)); } } for (int i = 0; i<10; i++) { cout << possible[i].first+1 << " "; } int printed = 0; for (int i = 10; i<possible.size(); i++) { if (printed >= 10) break; if (possible[i].second < 2) { cout << possible[i].first + 1 << " "; printed++; } } cout << "\n"; }
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 | #include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; vector< pair<int,int> > possible; for (int i = 0; i<n; i++) { string s; cin >> s; int x; cin >> x; if(s[0]=='T') { possible.push_back(make_pair(i, x)); } } for (int i = 0; i<10; i++) { cout << possible[i].first+1 << " "; } int printed = 0; for (int i = 10; i<possible.size(); i++) { if (printed >= 10) break; if (possible[i].second < 2) { cout << possible[i].first + 1 << " "; printed++; } } cout << "\n"; } |