标签:span play std src || 基本 pre alc ==
〖模板代码〗
1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #define LL long long 5 using namespace std; 6 const int N=1e5+10; 7 int n,len,a[N]; 8 int read() 9 { 10 int x=0,f=1;char c=getchar(); 11 while(c<‘0‘||c>‘9‘){if(c==‘-‘)f=-1;c=getchar();} 12 while(c>=‘0‘&&c<=‘9‘){x=x*10+c-‘0‘;c=getchar();} 13 return x*f; 14 } 15 int main() 16 { 17 n=read(); 18 for(int i=1;i<=n;i++) 19 { 20 a[i]=read();len=i; 21 while(len!=1) 22 { 23 if(a[len]<a[len/2])swap(a[len],a[len/2]); 24 else break;len>>=1; 25 } 26 } 27 for(int i=1;i<=n;i++) 28 { 29 printf("%d ",a[1]); 30 a[1]=a[n-i+1];len=1; 31 while(len*2<=n-i) 32 { 33 int next=len*2; 34 if(a[next]>a[next+1]&&next<n-i)next++; 35 if(a[len]<=a[next])break; 36 swap(a[len],a[next]);len=next; 37 } 38 } 39 return 0; 40 }
〖模板代码〗
1 int main() 2 { 3 while(r-l>1e-6) 4 { 5 mid1=l+(r-l)/3;mid2=r-(r-l)/3; 6 if(calc(mid1)<calc(mid2))l=mid1; 7 else r=mid2; 8 } 9 }
标签:span play std src || 基本 pre alc ==
原文地址:https://www.cnblogs.com/zsnuo/p/7793456.html