HDU多校Round 1
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的更多相关文章
- HDU多校Round 8
Solved:2 rank:141 D. Parentheses Matrix n,m有一个小于6的时候是一种构造方法 答案是n + (m - 2) / 2 (n > m) 都大于6的时候 可以 ...
- HDU多校Round 7
Solved:2 rank:293 J. Sequense 不知道自己写的什么东西 以后整数分块直接用 n / (n / i)表示一个块内相同n / i的最大i #include <bits/s ...
- HDU多校Round 6
Solved:2 rank:452 I. Werewolf 没有铁人 找铁狼 如果一个环中只有一条狼人边那个人就是铁狼 说铁狼是好人的人也是铁狼 #include <bits/stdc++.h& ...
- HDU多校Round 5
Solved:3 rank:71 E. Everything Has Changed #include <bits/stdc++.h> using namespace std; const ...
- HDU多校Round 4
Solved:3 rank:405................................. B. Harvest of Apples 知道了S(n,m) 可以o(1)的求S(n - 1, m ...
- HDU多校Round 3
Solved:4 rank:268 C. Dynamic Graph Matching 状压DP一下 #include <stdio.h> #include <algorithm& ...
- hdu 5667 BestCoder Round #80 矩阵快速幂
Sequence Accepts: 59 Submissions: 650 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
- hdu 5643 BestCoder Round #75
King's Game Accepts: 249 Submissions: 671 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 6 ...
- hdu 5641 BestCoder Round #75
King's Phone Accepts: 310 Submissions: 2980 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
随机推荐
- 图像处理之基础---yuv420及其rgb,bayer, yuv, RGB的相互转换详解
YUV格式解析1(播放器——project2) 根据板卡api设计实现yuv420格式的视频播放器 打开*.mp4;*.264类型的文件,实现其播放. 使用的视频格式是YUV420格式 YUV格式 ...
- [计算机故障处理]EXCEL文件双击不能直接打开
同事的电脑里的EXCEL文件不知什么原因双击不能直接打开了,双击只能打开软件而且是没有任何表格的,但通过软件中的“打开”再找到指定的文件能打开. 解决方案: 打开excel,依次选择:工具-选项-常规 ...
- 2016/2/22 1、Window.document对象
1.Window.document对象 一.找到元素: docunment.getElementById("id"):根据id找,最多找一个: var a =docunme ...
- Bootstrap popover源码分析
/* ======================================================================== * Bootstrap: popover.js ...
- hibernate 下载
https://sourceforge.net/projects/hibernate/files/hibernate-orm/5.0.7.Final/ http://sourceforge.net/p ...
- 【BZOJ 4353】 Play with tree
[题目链接] 点击打开链接 [算法] 树链剖分 对于线段树的每个节点,记录这段区间的最小值,最小值的个数,值为0的个数,此外,还要维护两个懒惰标记 [代码] 本题细节很多,写程序时要认真严谨! #in ...
- 深入理解JMM(Java内存模型) --(四)volatile
volatile的特性 当我们声明共享变量为volatile后,对这个变量的读/写将会很特别.理解volatile特性的一个好方法是:把对volatile变量的单个读/写,看成是使用同一个监视器锁对这 ...
- [App Store Connect帮助]四、添加 App 图标、App 预览和屏幕快照(5)移除 App 预览或屏幕快照
您可以随时移除 App 预览,但仅可在 App 状态为可编辑时才能移除屏幕快照.要了解可编辑的状态,请前往 App 状态. 必要职能:“帐户持有人”职能.“管理”职能.“App 管理”职能或“营销”职 ...
- (DP)51NOD 1049 最大子段和
N个整数组成的序列a[1],a[2],a[3],…,a[n],求该序列如a[i]+a[i+1]+…+a[j]的连续子段和的最大值.当所给的整数均为负数时和为0. 例如:-2,11,-4,13,-5 ...
- Oracle11gR2设置连接数process与会话session值
近日构建的Web应用用户数量有所上升,后台总是打印无法打开数据库连接的错误信息: 000000a3 SystemOut O 9月 ::, ERROR - msg:打开数据库出错. 经查询发现需要更改数 ...