uva 10474 Solution - Where is the Marble?
#include<iostream> #include<set> #include<algorithm> using namespace std; int main(){ multiset<int> myset; multiset<int>::iterator msit; int n,q,x,i,kase=1; while(cin>>n>>q){ if(n==0 && q==0) break; myset.clear(); for(i=0;i<n;i++){ cin>>x; myset.insert(x); } cout<<"CASE# "<<kase++<<":"<<endl; for(i=0;i<q;i++){ cin>>x; msit=myset.find(x); if(msit==myset.end()) cout<<x<<" not found"<<endl; else cout<<x<<" found at "<<distance(myset.begin(),msit)+1<<endl; } } return 0; }