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: ...
随机推荐
- 第一天,Robert和Sue大师培训给的启示
程序猿的零点从他睡觉那一刻开始计时. 今天是周六,听到了Robert关于销售技巧的培训还有Sue关于微信零售业O2O电商的分析,一并加上昨天晚上直到11点的Leadership培训,这个周末真的是收获 ...
- 免安装版TOMCAT配置及问题解决方法
前言 本文将介绍下面几点内容: 1.Tomcat的配置过程 2.启动startup过程中遇到的问题的解决 3.假设遇到本文中没有提到的问题怎样解决 配置 计算机右击->属性->高级系统设置 ...
- Matplotlib作图基础
折线图 import matplotlib.pylab as pylab import numpy as npy x=[1,2,3,4,8] y=[5,7,2,1,5] #折线图 pylab.plot ...
- JOIN a table with a subquery
统计数据产品消耗量与产量 注意join 方向 join中子查询 How to use subquery in JOIN operation in MySQL http://www.geeksengin ...
- oss
import oss2 ''' auth = oss2.Auth('您的AccessKeyId', '您的AccessKeySecret') bucket = oss2.Bucket(auth, '您 ...
- android7.0 编译问题及解决【转】
本文转载自:http://blog.csdn.net/zhangmingbao2016/article/details/52699182 注意:Linux操作系统上编译Android 7.0必须使用o ...
- Codeforces Round #395 (Div. 1)
比赛链接:http://codeforces.com/contest/763 A题: #include <iostream> #include <cstdio> #includ ...
- java笔记线程方式1线程暂停yield
public static void yield():暂停当前正在执行的线程对象,并执行其他线程. 让多个线程的执行更和谐,但是不能靠它保证一人一次. public class ThreadYield ...
- Tomcat启动Web.xml引用其它XML配置报FileNotFound异常解决方案
如果使用JEECG框架进行Tomcat启动时,如果web.xml引用了其他xml文件,需要在tomcat文件夹里的config文件夹里的context.xml文件里的Context标签里配置xmlBl ...
- P3154 [CQOI2009]循环赛
传送门 双倍经验题->这里 //minamoto #include<bits/stdc++.h> #define ll unsigned long long #define R re ...