Running Median 2009 Greater New York Regional
2010-11-22 08:46
253 查看
#include<iostream> #include<set> using namespace std; int main() { int n; cin>>n; for(int i=1;i<=n;i++) { int test; int inme; cin>>test>>inme; multiset<int> s; int temp; cin>>temp; s.insert(temp); int countt=0; countt++; cout<<test<<" "<<(inme+1)/2<<endl; if(inme==1)cout<<temp<<endl; else cout<<temp<<" "; for(int j=1;j<(inme+1)/2;j++) { int t1,t2; cin>>t1>>t2; s.insert(t1); s.insert(t2); multiset<int>::iterator it; it=s.begin(); for(int k=1;k<=j;k++) it++; if(j==(inme+1)/2-1&&i!=n)cout<<(*it)<<endl; else if(j==(inme+1)/2-1&&i==n)cout<<(*it); else { countt++; if(countt==10)cout<<(*it)<<endl,countt=0; else cout<<(*it)<<" "; } } s.clear(); } return 1; }
主要思想 每一次来两个元素执行插入排序!因为我的程序第一个元素拿出来但讨论了,结果在一个元素的地方格式错误了n次!
相关文章推荐
- Poj(2407),Greater New York Regional 2015 (D)
- 【2011 Greater New York Regional 】Problem B The Rascal Triangle
- 【2011 Greater New York Regional 】Problem H: Maximum in the Cycle of 1
- 【2011 Greater New York Regional 】Problem G: Rancher's Gift
- 【2011 Greater New York Regional 】Problem I :The Golden Ceiling
- 【组队赛#6 Greater New York Regional 2009】解题总结
- Problem B - Run Step 2015 ACM/ICPC Greater New York Region
- Problem A - Sum Kind Of Problem 2015 ACM/ICPC Greater New York Region
- Problem D - Farey Sequence Length 2015 ACM/ICPC Greater New York Region
- Problem E - A Rational Sequence 2015 ACM/ICPC Greater New York Region
- 电影 纽约黑帮 Gangs of New York
- Sun Microsystems brings MySQL Training to New York
- New York && Boston 省钱游记
- 【心情】期待 Mr. Jack In New York!
- New York Comic Con 2013 - 2013年纽约动漫展
- New York City . Manhattan
- 导读:有多少人知道链接的生命周期有多久?《纽约时报》(New York Times)的专利作家尼克·毕尔顿(Nick Bilton)今天发表了一篇文章,引用了互联网连接分析机构BitLy提供的分析报告
- 【每天积累一点点】Humans of New York
- Korea:KOTRA to host Korean Preview in New York during Sep 7-8, 2005
- [ZZ]Sign Up for the First-Ever Appium Roadshow on August 20th in New York City