#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = a; i < b;++i)
#define pb push_back
#define pi pair<int,int>
#define f first
#define s second
using namespace std;
int main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
int n;
cin>>n;
vector<pi> V;
vector<int> odp;
FOR(i,0,n){
string W;
cin>>W;
int x;
cin>>x;
if(W == "TAK"){
V.pb({i + 1,x});
}
}
sort(V.begin(),V.end());
FOR(i,0,10){
odp.pb(V[i].f);
}
int poz = 10;
FOR(i,10,V.size()){
if(V[i].s < 2){
--poz;
odp.pb(V[i].f);
}
if(poz == 0){break;}
}
for(auto y : odp){
cout<<y <<" ";
}
}
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 | #include <bits/stdc++.h> #define FOR(i,a,b) for(int i = a; i < b;++i) #define pb push_back #define pi pair<int,int> #define f first #define s second using namespace std; int main(){ cin.tie(0); ios_base::sync_with_stdio(0); int n; cin>>n; vector<pi> V; vector<int> odp; FOR(i,0,n){ string W; cin>>W; int x; cin>>x; if(W == "TAK"){ V.pb({i + 1,x}); } } sort(V.begin(),V.end()); FOR(i,0,10){ odp.pb(V[i].f); } int poz = 10; FOR(i,10,V.size()){ if(V[i].s < 2){ --poz; odp.pb(V[i].f); } if(poz == 0){break;} } for(auto y : odp){ cout<<y <<" "; } } |
English