#include <bits/stdc++.h> using namespace std; typedef long long ll; #define vc vector #define st first #define nd second #define pll pair<ll, ll> #define sz(a) (ll)a.size() #define all(a) a.begin(), a.end() #define pu push #define pub push_back #define pob pop_back #define em emplace #define emb emplace_back const ll INF = 2e18; void program() { ll n; cin >> n; map<ll, ll> a; for (ll i = 0; i < n; i++) { string s; ll x; cin >> s >> x; if (s == "TAK") { a[i] = x; } } for (ll i = 0; i < 10; i++) { cout << a.begin()->st + 1 << " "; a.erase(a.begin()); } for (ll i = 0; i < 10; i++) { while (a.begin()->nd >= 2) a.erase(a.begin()); cout << a.begin()->st + 1 << " "; a.erase(a.begin()); } cout << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); program(); 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 | #include <bits/stdc++.h> using namespace std; typedef long long ll; #define vc vector #define st first #define nd second #define pll pair<ll, ll> #define sz(a) (ll)a.size() #define all(a) a.begin(), a.end() #define pu push #define pub push_back #define pob pop_back #define em emplace #define emb emplace_back const ll INF = 2e18; void program() { ll n; cin >> n; map<ll, ll> a; for (ll i = 0; i < n; i++) { string s; ll x; cin >> s >> x; if (s == "TAK") { a[i] = x; } } for (ll i = 0; i < 10; i++) { cout << a.begin()->st + 1 << " "; a.erase(a.begin()); } for (ll i = 0; i < 10; i++) { while (a.begin()->nd >= 2) a.erase(a.begin()); cout << a.begin()->st + 1 << " "; a.erase(a.begin()); } cout << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); program(); return 0; } |