UVa11136

2014-11-24 01:44:18 · 作者: · 浏览: 2

搞不懂Submission Error是什么类型的错误。。。


[cpp]
#include
#include
#include

using namespace std;

int main()
{
ios::sync_with_stdio(false);
int n;
while(cin>>n && n)
{
int sum = 0;
multiset a;
while(n--)
{
int t;
cin>>t;
while(t--)
{
int temp;
cin>>temp;
a.insert(temp);
}
set::iterator it_max = max_element(a.begin(),a.end());
set::iterator it_min = min_element(a.begin(),a.end());
sum += (*it_max) - (*it_min);
a.erase(it_max);
a.erase(it_min);
}
cout< }
}

#include
#include
#include

using namespace std;

int main()
{
ios::sync_with_stdio(false);
int n;
while(cin>>n && n)
{
int sum = 0;
multiset a;
while(n--)
{
int t;
cin>>t;
while(t--)
{
int temp;
cin>>temp;
a.insert(temp);
}
set::iterator it_max = max_element(a.begin(),a.end());
set::iterator it_min = min_element(a.begin(),a.end());
sum += (*it_max) - (*it_min);
a.erase(it_max);
a.erase(it_min);
}
cout< }
}

估计会超时,改成优先队列会好很多