#include <iostream> using namespace std; int n,a; int f=0; int ma=0,mai; string slowo; int main() { cin>>n; int t[n]={0}; bool tb[n]={false}; for(int i=0; i<n; i++){ cin>>slowo>>a; if(slowo=="TAK") t[i]=a+1; } for(int i=0; i<n; i++){ if(f==10) break; else{ if(t[i]>0){ tb[i]=true; t[i]=0; f++; } } } for(int i=0; i<n; i++){ if(t[i]>2) t[i]=0; } f=0; for(int i=0; i<n; i++){ if(f==10) break; else{ if(t[i]>0){ tb[i]=true; t[i]=0; f++; } } } for(int i=0; i<n; i++){ if(tb[i]==true) cout<<i+1<<" "; } 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 | #include <iostream> using namespace std; int n,a; int f=0; int ma=0,mai; string slowo; int main() { cin>>n; int t[n]={0}; bool tb[n]={false}; for(int i=0; i<n; i++){ cin>>slowo>>a; if(slowo=="TAK") t[i]=a+1; } for(int i=0; i<n; i++){ if(f==10) break; else{ if(t[i]>0){ tb[i]=true; t[i]=0; f++; } } } for(int i=0; i<n; i++){ if(t[i]>2) t[i]=0; } f=0; for(int i=0; i<n; i++){ if(f==10) break; else{ if(t[i]>0){ tb[i]=true; t[i]=0; f++; } } } for(int i=0; i<n; i++){ if(tb[i]==true) cout<<i+1<<" "; } return 0; } |