Huangc 2013-04-26 22:10:00
点我顶贴
收藏
删除
测试结果1: 通过本测试点|有效耗时281ms
测试结果2: 通过本测试点|有效耗时62ms
测试结果3: 通过本测试点|有效耗时94ms
测试结果4: 通过本测试点|有效耗时125ms
测试结果5: 通过本测试点|有效耗时375ms
测试结果6: 通过本测试点|有效耗时610ms
测试结果7: 通过本测试点|有效耗时469ms
测试结果8: 选手程序运行超过时限
测试结果9: 选手程序运行超过时限
测试结果10: 通过本测试点|有效耗时47ms
#include<iostream>
using namespace std;
long long b[200001];
int n,g;
void kp(int l,int r)
{
int i=l,j=r,x,t;
x=b[(i+j)/2];
while(i<=j)
{
while (b[i]<x) i++;
while (b[j]>x) j--;
if (i<=j)
{t=b[i];b[i]=b[j];b[j]=t;i++;j--;}
}
if (l<j) kp(l,j);
if (i<r) kp(i,r);
}
int main()
{
cin >> n;
for (int i=1;i<=n;i++)
cin >> b[i];
kp(1,n);
for(int a=1;a<=n;a++)
{
g=1;
while(b[a+g-1]==b[a])
g++;
g--;
cout << b[a];
cout << " " << g << endl;
a=a+g-1;
}
return 0;
}