我超了n次,都是8,9两数据超,找不到原因。
后来想到iostream好像比stdio要慢,于是乎,我改下试试。AC!
碰到较大数据都不要用iostream,用stdio啊~~
测试结果1: 通过本测试点|有效耗时62:ms
测试结果2: 通过本测试点|有效耗时62:ms
测试结果3: 通过本测试点|有效耗时78:ms
测试结果4: 通过本测试点|有效耗时125:ms
测试结果5: 通过本测试点|有效耗时375:ms
测试结果6: 通过本测试点|有效耗时562:ms
测试结果7: 通过本测试点|有效耗时453:ms
测试结果8: 选手程序运行超过时限
测试结果9: 选手程序运行超过时限
测试结果10: 通过本测试点|有效耗时47:ms
#include <iostream>
using namespace std;
int s[200000];
void qsort (int lx,int rx)
{
int i,j,t;
i=lx; j=rx; t=s[i];
while (i!=j)
{
while (s[j]>t && j>i) j--;
if (i<j) {
s[i]=s[j];
i++;
while (s[i]<t && i<j) i++;
if (i<j) {
s[j]=s[i];
j--;
}
}
}
s[i]=t; i++; j--;
if (lx<j) qsort (lx,j);
if (i<rx) qsort (i,rx);
}
int main ()
{
int n,i,total;
cin>>n;
for (i=0; i<n; i++)
cin>>s[i];
qsort(0,n-1);
cout<<s[0];
total=1;
for (i=1; i<n; i++)
if (s[i]==s[i-1]) total++;
else {
cout<<’ ’<<total<<endl;
cout<<s[i];
total=1;
}
cout<<’ ’<<total<<endl;
return 0;
}