|
|
back to boardOh, yeeee... : 2569031 14:54:48 19 апр 2009 Gerasim Petrov Velchev 1126 C++ Accepted 0.187 829 КБ #include<iostream> #include<queue> #include<vector> using namespace std; int izv[100001]; int main(){ int m; cin>>m; priority_queue<int>k; vector<int>x; int a,br=0; while(1) { cin>>a; if(a==-1)break; x.push_back(a); k.push(a); br++; if(br==m)cout<<k.top()<<endl; else if(br>m) { izv[x[0]]++; x.erase(x.begin()); while(izv[k.top()]){izv[k.top()]--;k.pop();} cout<<k.top()<<endl; } }
system("pause"); return 0; } Re: Oh, yeeee... : 2569031 14:54:48 19 апр 2009 Gerasim Petrov Velchev 1126 C++ Accepted 0.187 829 КБ well,can you give some more details about your algorithm? I can't quite understand your algorithm.....thx Re: Oh, yeeee... : 2569031 14:54:48 19 апр 2009 Gerasim Petrov Velchev 1126 C++ Accepted 0.187 829 КБ No necessary in such a ugly algorithm, simple multiset works fine and fast upd. map also works, and is faster Edited by author 10.08.2011 02:37 |
|
|