cf 204 div2 D. Jeff and Furik 逆序对
来源:互联网 发布:数据库导入excle 编辑:程序博客网 时间:2024/05/17 02:59
又一次看错题意……题目是两个人,一个人自己主观选择,一个人抛硬币,因为算期望,所以抛硬币那人可以无视掉,求出逆序对个数m,m为奇答案是2m-1,否则2m
太囧
#include<iostream>#include<cstdlib>#include<cstdio>#include<algorithm>using namespace std;int org[100000];int c[100000];int ans=0;void out(int *a,int n){ for(int i=0;i<n;i++) printf("%d ",a[i]); puts("");}int meg(int l,int mid,int r){ int i=l,j=mid+1,k=0; while(i<=mid) { while(j<=r&&org[i]>org[j]) c[k++]=org[j++]; ans+=j-mid-1; c[k++]=org[i++]; } while(j<=r)c[k++]=org[j++]; k=0; while(l<=r)org[l++]=c[k++];}void count(int l,int r){ if(l<r) { int mid=(l+r)>>1; count(l,mid); count(mid+1,r); meg(l,mid,r); }}int main(){ int n; while(~scanf("%d",&n)) { ans=0; int i; for(i=0;i<n;i++) scanf("%d",&org[i]); count(0,n-1); double t; if(ans%2==0)ans*=2; else ans=ans*2-1; printf("%.6f\n",(double)(ans)); }}
- cf 204 div2 D. Jeff and Furik 逆序对
- CodeForces 351B Jeff and Furik 概率DP 逆序对
- [CF 351B]Jeff and Furik[归并排序求逆序数]
- CF#204DIV2:A. Jeff and Digits
- CF#204DIV2:B. Jeff and Periods
- cf 204 div2 C Jeff and Rounding 模拟
- CodeForces-352D Jeff and Furik(递推)
- CF #261 Div2 D. Pashmak and Parmida's problem (离散化+逆序对+线段树)
- B. Jeff and Furik----数学期望
- CodeForce 204 Div2. C Jeff And Rounding
- Codeforces Round #204 (Div. 1) B. Jeff and Furik 1月7日
- cf#204-div1 -D - Jeff and Removing Periods-莫队算法-维护等差数列
- CodeForces 351B Jeff and Furik(YY题)
- codeforces 351B B. Jeff and Furik(概率)
- CodeForces 351 B.Jeff and Furik(概率DP)
- CF(#294 div2):D. A and B and Interesting Substrings
- CF 174(div2) D
- CF 161 div2 D
- UVALive 4957 Fake scoreboard
- org.xml.sax.SAXParseException
- 7.4
- 黑马程序员_<<properties,打印流,合并流,分割流>>
- 内存对齐规则
- cf 204 div2 D. Jeff and Furik 逆序对
- 人人网2012 年校招Android 笔试题
- android:gravity和android:layout_gravity
- UKICPC
- Android 之 下拉框(Spinner)的使用
- Eclipse+PyDev
- Apache CXF REST example
- UVALive 4959 Jumping monkey
- 软件架构师的12项修炼_读书纪要_P3商务技能修炼