zoukankan      html  css  js  c++  java
  • cf B Inna and Candy Boxes

    题意:输入n,然后输入n个数ai,再输入n个数bi,如果在1-ai中能找到两个数x,y,x和y可以相等,如果x+y=bi,答案加上x*y,否则减去1,让结果尽可能大,输出结果。

     1 #include <cstdio>
     2 #include <cstring>
     3 #include <algorithm>
     4 #define ll long long
     5 #define maxn 100100
     6 using namespace std;
     7 
     8 int n;
     9 ll a[maxn],b[maxn];
    10 
    11 int main()
    12 {
    13     while(scanf("%d",&n)!=EOF)
    14     {
    15         memset(a,0,sizeof(a));
    16         memset(b,0,sizeof(b));
    17         for(int i=1; i<=n; i++)
    18         {
    19             scanf("%lld",&a[i]);
    20         }
    21         for(int i=1; i<=n; i++)
    22         {
    23             scanf("%lld",&b[i]);
    24         }
    25         ll ans=0;
    26         for(int i=1; i<=n; i++)
    27         {
    28             if(b[i]==1)
    29             {
    30                 ans--;
    31                 continue;
    32             }
    33             if(b[i]-a[i]>a[i])
    34             {
    35                 ans--;
    36                 continue;
    37             }
    38             if(b[i]%2==0)
    39                 ans+=(ll)((ll)(b[i]/2)*(ll)(b[i]/2));
    40             else
    41                 ans+=(ll)((ll)(b[i]/2)*(ll)(b[i]/2+1));
    42         }
    43         printf("%lld
    ",ans);
    44     }
    45     return 0;
    46 }
    View Code
  • 相关阅读:
    用jQuery写的一个简单的弹出窗口(IE7\IE8\FF3)
    live write test
    sql2
    查询所有表索引
    java初学问题记录(2012.02.092012.02.16)
    SQL
    centso7网卡bond
    vmware模板
    Dockerfile参考
    Docker简单介绍
  • 原文地址:https://www.cnblogs.com/fanminghui/p/4248939.html
Copyright © 2011-2022 走看看