A题
http://codeforces.com/contest/950/problem/A
题意:给定三个数l,r,a,要我们求min(l+a1,r+a2)的最大值再乘以2;a1+a2<=a。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
1 #include2 using namespace std; 3 4 typedef long long ll; 5 const int maxn=1e5+10; 6 7 int l,r,a; 8 9 int main()10 {11 while(scanf("%d %d %d",&l,&r,&a)!=EOF)12 {13 if(l>r)14 swap(l,r);15 int t=r-l;16 if(t>=a)17 {18 printf("%d\n",2*(l+a));19 }20 else if(t
B题
http://codeforces.com/contest/950/problem/B
题意:给定两个数组x[],y[](∑xi=∑yi),从x数组中选择连续的几个数求和,让它等于从y数组中选择出连续的几个数的和(选取过的数不能在选择),问最大能有多少中匹配方法!
其实从给出的数据来推导比看题意更容易明白-.v.-。看题意没有看数据容易明白点。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
1 #include2 using namespace std; 3 4 typedef long long ll; 5 const int maxn=1e5+10; 6 7 int n,m; 8 int x[maxn],y[maxn]; 9 int main()10 {11 scanf("%d %d",&n,&m);12 for(int i=1; i<=n; i++)13 {14 scanf("%d",&x[i]);15 }16 for(int i=1; i<=m; i++)17 {18 scanf("%d",&y[i]);19 }20 int a=x[1],b=y[1];21 22 int ans=0;23 24 for(int i=1,j=1; i<=n;)25 {26 if(a==b)27 {28 i++,j++;29 ans++;30 a=x[i];31 b=y[j];32 continue;33 }34 if(a b)40 {41 j++;42 b+=y[j];43 }44 }45 printf("%d\n",ans);46 return 0;47 }
A/B这两道题比较水,所以一起发出来,等会在苦述悲催的C题把!~ !