Solved:5

rank:172

A.Maximum Multiple

#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll; int main()
{
int T;
scanf("%d", &T);
while(T--)
{
int n;
scanf("%d", &n);
ll ans = -;
if(n % == )
{
ll x = n / ;
ans = max(ans, x * x * x);
}
if(n % == )
{
ll x = n / ;
ans = max(ans, x * x * x * );
}
printf("%lld\n", ans);
}
return ;
}

B.Balanced Sequence

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string.h>
using namespace std; char s[];
struct node
{
int l, r;
}E[]; bool cmp(node A, node B)
{
int tmp1 = min(A.l, B.r);
int tmp2 = min(A.r, B.l);
if(tmp1 == tmp2) return A.r < B.r;
else return tmp1 > tmp2;
} int main()
{
int T;
scanf("%d", &T);
while(T--)
{
int ans = ; int cnt = ;
int suml = , sumr = ;
int n;
scanf("%d", &n);
for(int i = ; i <= n; i++)
{
scanf("%s", s);
int len = strlen(s); int cnl = , cnr = ;
for(int j = ; j < len; j++)
{
if(s[j] == '(') cnl++;
else
{
if(cnl)
{
cnl--;
ans += ;
}
else cnr++;
}
}
if(cnl == ) sumr += cnr;
else if(cnr == ) suml += cnl;
else
{
cnt++;
E[cnt].l = cnl;
E[cnt].r = cnr;
}
}
sort(E + , E + + cnt, cmp); for(int i = ; i <= cnt; i++)
{
if(suml >= E[i].r)
{
ans += E[i].r * ;
suml -= E[i].r;
suml += E[i].l;
}
else
{
ans += suml * ;
suml = E[i].l;
}
}
ans += min(suml, sumr) * ;
printf("%d\n", ans);
}
return ;
}

HDU多校Round 1的更多相关文章

  1. HDU多校Round 8

    Solved:2 rank:141 D. Parentheses Matrix n,m有一个小于6的时候是一种构造方法 答案是n + (m - 2) / 2 (n > m) 都大于6的时候 可以 ...

  2. HDU多校Round 7

    Solved:2 rank:293 J. Sequense 不知道自己写的什么东西 以后整数分块直接用 n / (n / i)表示一个块内相同n / i的最大i #include <bits/s ...

  3. HDU多校Round 6

    Solved:2 rank:452 I. Werewolf 没有铁人 找铁狼 如果一个环中只有一条狼人边那个人就是铁狼 说铁狼是好人的人也是铁狼 #include <bits/stdc++.h& ...

  4. HDU多校Round 5

    Solved:3 rank:71 E. Everything Has Changed #include <bits/stdc++.h> using namespace std; const ...

  5. HDU多校Round 4

    Solved:3 rank:405................................. B. Harvest of Apples 知道了S(n,m) 可以o(1)的求S(n - 1, m ...

  6. HDU多校Round 3

    Solved:4 rank:268 C. Dynamic Graph Matching  状压DP一下 #include <stdio.h> #include <algorithm& ...

  7. hdu 5667 BestCoder Round #80 矩阵快速幂

    Sequence  Accepts: 59  Submissions: 650  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536 ...

  8. hdu 5643 BestCoder Round #75

    King's Game  Accepts: 249  Submissions: 671  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 6 ...

  9. hdu 5641 BestCoder Round #75

    King's Phone  Accepts: 310  Submissions: 2980  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: ...

随机推荐

  1. Python爬虫开发【第1篇】【Requests】

    1.安装 利用 pip 安装 或者利用 easy_install 都可以完成安装: pip install requests easy_install requests 2.基本GET请求(heade ...

  2. POJ 3281 Dining(最大流)

    POJ 3281 Dining id=3281" target="_blank" style="">题目链接 题意:n个牛.每一个牛有一些喜欢的 ...

  3. java 开发webservice

    这几天用java开发一个webservice,搞死了.java果然很难侍候! 传说java搞webservice,有好几种途径(为什么不是一种?要搞这么多种,让人一听,头都大了.当然啦,生物多样性总是 ...

  4. UVA - 12345 带修改的莫队

    题意显然:给出初始序列,单点修改,区间查询元素的种类. 由于时限过宽,暴力可过. 比较优秀的解法应该是莫队. 带修改的莫队题解可以看https://www.luogu.org/blog/user126 ...

  5. bzoj4869

    http://www.lydsy.com/JudgeOnline/problem.php?id=4869 终于A了...参考了下dalao的代码... 拓展欧几里得定理,改了几次就不变了,但是用的时候 ...

  6. 用户能够在下次登录系统时被重新配置---或win10早期更新不成功的bug就需要删除多余的登陆用户

    有时候我们希望删除本地计算机上的一位用户,或者期待一位用户能够在下次登录系统时被重新配置.但是仅删除%userprofile%目录是不够的,因为一个登录名会对应一个SSID,这个SSID还保留在注册表 ...

  7. 【152】C# 操作 Excel 杂记

    前面写了一篇博文是关于 C# 操作 Excel 的文章,但是里面有些中规中矩,搞的我不知道怎么写了,所以另开一帖.. 注意:基本应用如下所示! //首先是引用 using Excel = Micros ...

  8. [Swift通天遁地]二、表格表单-(1)创建自定义的UITableViewCell(单元格类)

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  9. WebSphere Application Server切换JAVA SDK版本

    最近在Windows Server 2008 R2服务器中搭建了一套IHS+WAS8.5集群环境,测试一个简单的demo应用没有问题,可是在部署正式应用时总是报类版本错误.换了好几个JDK对项目进行编 ...

  10. 一行python能做什么!

    主要收集了平常遇到的代码和网上的简单题目,然后尝试将代码压缩到一行,仅仅是娱乐一下~~~ −−−−−(1)−−−−−−−−−−−(1)−−−−−− 用一行python写出一个嵌套的字符串. def p ...